Example #1
0
static void DoSimpleCommand(int cmd)
{
 switch(cmd)
 {
  case MDFN_MSC_POWER: system_reset(true); break;
  case MDFN_MSC_RESET: system_reset(false); break;
 }
}
Example #2
0
static void DoSimpleCommand(int cmd)
{
 switch(cmd)
 {
  case MDFN_MSC_POWER: system_reset(); break;
  case MDFN_MSC_RESET: if(IS_SMS)
			{
			 input.system |= INPUT_RESET;
			 SoftResetCount = 20;
			}
			else
			 system_reset();
			break;
 }
}
Example #3
0
/**************************************************
  Load a new rom and performs some initialization
***************************************************/
void reloadrom (int size, char *name)
{
  /* cartridge hot-swap support */
  uint8 hotswap = 0;
  if (cart.romsize) hotswap = config.hot_swap;

  /* Load ROM */
  cart.romsize = size;
  load_rom(name);

  if (hotswap)
  {
    cart_hw_init();
    cart_hw_reset();
  }
  else
  {
    /* initialize audio back-end */
    /* 60hz video mode requires synchronization with Video Interrupt.    */
    /* VSYNC period is 16715 us on Wii/Gamecube (approx. 802.32 samples per frame) */
    float framerate;
    if (vdp_pal)
      framerate = 50.0;
    else
      framerate = ((config.tv_mode == 0) || (config.tv_mode == 2)) ? (1000000.0/16715.0) : 60.0;
    audio_init(48000, framerate);

    /* System Power ON */
    system_init ();
    ClearGGCodes ();
    system_reset ();
  }
}
Example #4
0
int main(void)
{
	void *rw_hash;

	hardware_init();
	debug_printf("%s started\n",
		is_ro_mode() ? "RO" : "RW");

	/* the RO partition protection is not enabled : do it */
	if (!flash_physical_is_permanently_protected())
		flash_physical_permanent_protect();

	/*
	 * calculate the hash of the RW partition
	 *
	 * Also pre-cache it so we can answer Discover Identity VDM
	 * fast enough (in less than 30ms).
	 */
	rw_hash = flash_hash_rw();

	/* Verify RW firmware and use it if valid */
	if (is_ro_mode() && check_rw_valid(rw_hash))
		jump_to_rw();

	/* background loop for PD events */
	pd_task();

	debug_printf("EXIT!\n");
	/* we should never reach that point */
	system_reset(0);
	return 0;
}
 int special_button_mappings(int controllerno, int specialbuttonmap)
 {
     if((specialbuttonmap != BTN_EXITTOMENU) &&
             (specialbuttonmap != BTN_QUICKSAVE) &&
             (specialbuttonmap != BTN_QUICKLOAD) &&
             (specialbuttonmap != BTN_SOFTRESET) &&
             (specialbuttonmap != BTN_HARDRESET))
     {
         input.pad[controllerno] |= specialbuttonmap;
     }
     else
     {
         switch(specialbuttonmap)
         {
         case BTN_SOFTRESET:
             gen_softreset(0);
             break;
         case BTN_HARDRESET:
             system_reset();
             break;
         case BTN_EXITTOMENU:
             Emulator_StopROMRunning();
             Emulator_SwitchMode(MODE_MENU);
             break;
         case BTN_QUICKSAVE:
             SaveState();
             break;
         case BTN_QUICKLOAD:
             LoadState();
             break;
         default:
             break;
         }
     }
 }
Example #6
0
void network_gm_reset(void)
{
	INT8S	res = 0;
//	INT8U 		err;
	gd_msg_t 	*send_msg = NULL;
	
	res = gprsmodule_reset();
	
	gd_msg_malloc(&send_msg);
	send_msg->data =  (void*)NULL;
	if(res == 0)	
	{
		fail_tick = 0;
		send_msg->type = GD_MSG_GM_INIT;
		OSQPost(gd_system.network_task.q_network, (void*)send_msg);	
	}
	else
	{
		fail_tick++;
		if(fail_tick >= NETWORK_FAIL_COUNT)
		{
			fail_tick = 0;
			OSQFlush(gd_system.network_task.q_network);
			//system reset
			system_reset();
		}
		else
		{
			send_msg->type = GD_MSG_GM_RESET;
		}
		OSQPost(gd_system.network_task.q_network, (void*)send_msg);	
	}

}
Example #7
0
/**
 * Handle a pending reboot command.
 */
static int handle_pending_reboot(enum ec_reboot_cmd cmd)
{
	switch (cmd) {
	case EC_REBOOT_CANCEL:
		return EC_SUCCESS;
	case EC_REBOOT_JUMP_RO:
		return system_run_image_copy(SYSTEM_IMAGE_RO);
	case EC_REBOOT_JUMP_RW:
		return system_run_image_copy(SYSTEM_IMAGE_RW);
	case EC_REBOOT_COLD:
		system_reset(SYSTEM_RESET_HARD);
		/* That shouldn't return... */
		return EC_ERROR_UNKNOWN;
	case EC_REBOOT_DISABLE_JUMP:
		system_disable_jump();
		return EC_SUCCESS;
	case EC_REBOOT_HIBERNATE:
		CPRINTS("system hibernating");
		system_hibernate(0, 0);
		/* That shouldn't return... */
		return EC_ERROR_UNKNOWN;
	default:
		return EC_ERROR_INVAL;
	}
}
Example #8
0
/**
 * Handle a pending reboot command.
 */
static int handle_pending_reboot(enum ec_reboot_cmd cmd)
{
	switch (cmd) {
	case EC_REBOOT_CANCEL:
		return EC_SUCCESS;
	case EC_REBOOT_JUMP_RO:
		return system_run_image_copy(SYSTEM_IMAGE_RO);
	case EC_REBOOT_JUMP_RW:
		return system_run_image_copy(SYSTEM_IMAGE_RW);
	case EC_REBOOT_COLD:
#ifdef HAS_TASK_PDCMD
		/* Reboot the PD chip as well */
		gpio_set_level(GPIO_USB_MCU_RST, 1);
		usleep(100);
		gpio_set_level(GPIO_USB_MCU_RST, 0);
#endif
		system_reset(SYSTEM_RESET_HARD);
		/* That shouldn't return... */
		return EC_ERROR_UNKNOWN;
	case EC_REBOOT_DISABLE_JUMP:
		system_disable_jump();
		return EC_SUCCESS;
#ifdef CONFIG_HIBERNATE
	case EC_REBOOT_HIBERNATE:
		CPRINTS("system hibernating");
		system_hibernate(0, 0);
		/* That shouldn't return... */
		return EC_ERROR_UNKNOWN;
#endif
	default:
		return EC_ERROR_INVAL;
	}
}
Example #9
0
static int command_reboot(int argc, char **argv)
{
	int flags = 0;
	int i;

	for (i = 1; i < argc; i++) {
		if (!strcasecmp(argv[i], "hard") ||
		    !strcasecmp(argv[i], "cold")) {
			flags |= SYSTEM_RESET_HARD;
		} else if (!strcasecmp(argv[i], "soft")) {
			flags &= ~SYSTEM_RESET_HARD;
		} else if (!strcasecmp(argv[i], "ap-off")) {
			flags |= SYSTEM_RESET_LEAVE_AP_OFF;
		} else if (!strcasecmp(argv[i], "cancel")) {
			reboot_at_shutdown = EC_REBOOT_CANCEL;
			return EC_SUCCESS;
		} else if (!strcasecmp(argv[i], "preserve")) {
			flags |= SYSTEM_RESET_PRESERVE_FLAGS;
		} else
			return EC_ERROR_PARAM1 + i - 1;
	}

	if (flags & SYSTEM_RESET_HARD)
		ccputs("Hard-");
	ccputs("Rebooting!\n\n\n");
	cflush();
	system_reset(flags);
	return EC_SUCCESS;
}
Example #10
0
/*-------------------------------------------------------------------*/
int ARCH_DEP(common_load_begin) (int cpu, int clear)
{
    int capture;
    int rc;

    /* Save the original architecture mode for later */
    orig_arch_mode = sysblk.dummyregs.arch_mode = sysblk.arch_mode;

    capture = (!clear) && IS_CPU_ONLINE(cpu) && sysblk.arch_mode == ARCH_900;

    /* Capture the z/Arch PSW if this is a Load-normal IPL */
    if (capture)
        captured_zpsw = sysblk.regs[cpu]->psw;

    /* Perform system-reset-normal or system-reset-clear function;
     * architecture mode updated, if necessary.
     */
    if ( (rc = ARCH_DEP(system_reset(cpu, clear,
                                     sysblk.arch_mode > ARCH_390 ?
                                     ARCH_390 : sysblk.arch_mode))) )
        return (rc);

    /* Save our captured-z/Arch-PSW if this is a Load-normal IPL
       since the initial_cpu_reset call cleared it to zero. */
    if (capture)
        sysblk.regs[cpu]->captured_zpsw = captured_zpsw;

    /* The actual IPL (load) now begins... */
    sysblk.regs[cpu]->loadstate = 1;

    return 0;
} /* end function common_load_begin */
Example #11
0
/*-------------------------------------------------------------------*/
int ARCH_DEP(common_load_begin) (int cpu, int clear)
{
    int capture;
    int rc;

    /* Save the original architecture mode for later */
    orig_arch_mode = sysblk.dummyregs.arch_mode = sysblk.arch_mode;
#if defined(OPTION_FISHIO)
    ios_arch_mode = sysblk.arch_mode;
#endif // defined(OPTION_FISHIO)

    capture = (!clear) && IS_CPU_ONLINE(cpu) && sysblk.arch_mode == ARCH_900;

    /* Capture the z/Arch PSW if this is a Load-normal IPL */
    if (capture)
        captured_zpsw = sysblk.regs[cpu]->psw;

    /* Switch architecture mode to ESA390 mode for z/Arch IPL */
    if (sysblk.arch_mode == ARCH_900)
        sysblk.arch_mode = ARCH_390;

    /* Perform system-reset-normal or system-reset-clear function */
    if ( (rc = ARCH_DEP(system_reset(cpu,clear))) )
        return rc;

    /* Save our captured-z/Arch-PSW if this is a Load-normal IPL
       since the initial_cpu_reset call cleared it to zero. */
    if (capture)
        sysblk.regs[cpu]->captured_zpsw = captured_zpsw;

    /* The actual IPL (load) now begins... */
    sysblk.regs[cpu]->loadstate = 1;

    return 0;
} /* end function common_load_begin */
Example #12
0
static void fake_hibernate_ac_hook(void)
{
	if (fake_hibernate && extpower_is_present()) {
		ccprints("%s() resets EC", __func__);
		cflush();
		system_reset(SYSTEM_RESET_HARD);
	}
}
Example #13
0
static void fake_hibernate_lid_hook(void)
{
	if (fake_hibernate && lid_is_open()) {
		ccprints("%s() resets EC", __func__);
		cflush();
		system_reset(SYSTEM_RESET_HARD);
	}
}
Example #14
0
void SimpleShell::on_second_tick(void*) {
    // we are timing out for the reset
    if (this->reset_delay_secs > 0) {
        if(--this->reset_delay_secs == 0){
            system_reset(false);
        }
    }
}
Example #15
0
extern uint8_t upgrade_process(uint8_t ev, uint16_t lparam, void* rparam)
{
	switch(ev)
	{
		case EVENT_WINDOW_CREATED:
			window_timer(CLOCK_SECOND * 30);
			break;
		case EVENT_FIRMWARE_UPGRADE:
			if (rparam == (void*)PROGRESS_TIMEOUT)
				break;

			if (rparam == (void*)-1)
			{
				progress = PROGRESS_FINISH;
				window_timer(0);
			}
			else
			{
				progress = (long)rparam * 100/(230UL*1024);
				window_timer(CLOCK_SECOND * 30);
			}
			window_invalid(NULL);
			break;
		case EVENT_WINDOW_PAINT:
			onDraw((tContext*)rparam);
		    break;
		case EVENT_EXIT_PRESSED:
			if (progress != PROGRESS_FINISH || progress != PROGRESS_TIMEOUT)
				return 1;
			break;
		case PROCESS_EVENT_TIMER:
			if (progress != PROGRESS_FINISH)
			{
				progress = PROGRESS_TIMEOUT;
				window_invalid(NULL);
			}
			break;
		case EVENT_KEY_PRESSED:
		 	if (lparam == KEY_ENTER)
		 	{
		 		if (progress == PROGRESS_FINISH)
		 		{
		 			int ret = CheckUpgrade();
		 			printf("CheckUpgrade() %d\n", ret);
		 			if (ret == 0xff)
		 				system_reset();
		 			else
		 				window_close();
		 		}
		 		else if (progress == PROGRESS_TIMEOUT)
		 		{
		 			window_close();
		 		}
		 	}
		 	break;
	}
	return 1;
}
Example #16
0
static void ther_handle_button(struct ther_info *ti, struct button_msg *msg)
{
	if (ti->powering_down)
		return;

	ther_user_active(ti);

	switch (msg->type) {
	case SHORT_PRESS:
		if (ti->power_mode == PM_ACTIVE) {
			struct display_param param;

			if (ti->display_picture > OLED_PICTURE_NONE) {
				print(LOG_DBG, MODULE "ignore button press when picture is %d\n", ti->display_picture);
				break;
			}

			encap_picture_param(ti, &param);
			if (ti->display_picture == OLED_PICTURE_NONE) {
				oled_show_picture(OLED_PICTURE1, DISPLAY_TIME, &param);

			} else {
				oled_show_next_picture(DISPLAY_TIME, &param);
			}

		} else if (ti->power_mode == PM_3) {
			print(LOG_DBG, MODULE "ignore short press, enter PM3 again\n");
			ther_enter_pm3(ti);
		} else {
			print(LOG_DBG, MODULE "unknown power mode\n");
		}

		break;

	case LONG_PRESS:

		if (ti->power_mode == PM_ACTIVE) {
			print(LOG_DBG, MODULE "power down system\n");
			ti->powering_down = TRUE;
			ther_system_power_off_pre(ti);

		} else if (ti->power_mode == PM_3) {

			print(LOG_DBG, MODULE "power up system(use reset system instead)\n");

//			start_watchdog_timer(10);
			system_reset();
		}

		break;

	default:
		print(LOG_WARNING, MODULE "unknow button press\n");
		break;
	}

	return;
}
Example #17
0
static void LoadCommon(MDFNFILE *fp)
{
 try
 {
  /* Assign default settings (US NTSC machine) */
  sms.display     = DISPLAY_NTSC;

  sms.territory   = MDFN_GetSettingI("sms.territory");
  sms.use_fm      = FALSE;

  Cart_Init(fp);
  Cart_LoadNV();

  if(IS_SMS && sms.territory == TERRITORY_DOMESTIC)
   sms.use_fm = MDFN_GetSettingB("sms.fm");

  MDFNMP_Init(1024, 65536 / 1024);

  system_assign_device(PORT_A, DEVICE_PAD2B);
  system_assign_device(PORT_B, DEVICE_PAD2B);

  MDFNMP_AddRAM(8192, 0xC000, sms.wram);

  sms_init();
  pio_init();
  vdp_init(IS_SMS && sms.territory == TERRITORY_DOMESTIC);
  render_init();

  MDFNGameInfo->GameSetMD5Valid = FALSE;

  uint32 sndclk;

  if(sms.display == DISPLAY_PAL)
  {
   sndclk = 3546893;
   MDFNGameInfo->fps = (uint32)((uint64)65536 * 256 * sndclk / 313 / 228); //6144000 * 65536 * 256 / 515 / 198); // 3072000 * 2 * 10000 / 515 / 198
  }
  else
  {
   sndclk = 3579545;
   MDFNGameInfo->fps = (uint32)((uint64)65536 * 256 * sndclk / 262 / 228); //6144000 * 65536 * 256 / 515 / 198); // 3072000 * 2 * 10000 / 515 / 198
  }

  MDFNGameInfo->MasterClock = MDFN_MASTERCLOCK_FIXED(sndclk);

  SMS_SoundInit(sndclk, sms.use_fm);

  sms.save = 0;

  system_reset();
 }
 catch(...)
 {
  Cleanup();
  throw;
 }
}
Example #18
0
static void OnConfigApplySound(AG_Event *event)
{
        int ver;
	AG_Button *self = (AG_Button *)AG_SELF();
	struct gui_sound *cfg = AG_PTR(1);


	LockVM();
	if(cfg != NULL){
	  configdat.iTotalVolume = cfg->iTotalVolume;
	  configdat.nFMVolume = cfg->nFMVolume;
	  configdat.nPSGVolume = cfg->nPSGVolume;
	  configdat.nBeepVolume = cfg->nBeepVolume;
	  configdat.nCMTVolume = cfg->nCMTVolume;
	  configdat.nWaveVolume = cfg->nWaveVolume;
	  configdat.uChSeparation = cfg->uChSeparation;
	  configdat.nSampleRate = cfg->nSampleRate;
	  configdat.nSoundBuffer = cfg->nSoundBuffer;
	  configdat.nBeepFreq = cfg->nBeepFreq;
	  configdat.bFMHQmode = cfg->bFMHQmode;
	  configdat.nStereoOut = cfg->nStereoOut;
	  configdat.bTapeMon = cfg->bTapeMon;
	  configdat.bOPNEnable = cfg->bOPNEnable;
	  configdat.bWHGEnable = cfg->bWHGEnable;
	  configdat.bTHGEnable = cfg->bTHGEnable;
#ifdef FDDSND
	  configdat.bFddSound = cfg->bFddSound;
#endif
	  free(cfg);
	}
	ver = fm7_ver;
	ApplyCfg();
	/*
	 * VMヴァージョンが違ったら強制リセット
	 */
	if(ver != fm7_ver){
		system_reset();
	}
	/*
	 * ここにアイコン変更入れる
	 */

	/*
	 * 終了処理
	 */
	UnlockVM();

	if(self != NULL) {
	  AG_WindowHide(self->wid.window);
	  AG_ObjectDetach(self);
	}


}
static void OnConfigApplyDisp(AG_Event *event)
{
        int ver;
	AG_Button *self = (AG_Button *)AG_SELF();
	struct gui_disp *cfg = (struct gui_disp *)AG_PTR(1);
	int i;

	LockVM();
	if(cfg != NULL){
	  configdat.nDrawFPS = cfg->nDrawFPS;
	  configdat.nEmuFPS = cfg->nEmuFPS;
	  configdat.nBrightness = cfg->nBrightness;
	  configdat.nRenderMethod = cfg->nRenderMethod;
	  configdat.uWidth = cfg->uWidth;
	  configdat.uHeight = cfg->uHeight;
	  configdat.bFullScan = cfg->bFullScan;
	  configdat.bFullScanFS = cfg->bFullScanFS;
	  configdat.bSmoosing = cfg->bSmoosing;
	  configdat.bUseSIMD = cfg->bUseSIMD; 
#ifdef _USE_OPENCL
	  configdat.bUseOpenCL = cfg->bUseOpenCL;
	  configdat.nCLGlobalWorkThreads = cfg->nCLGlobalWorkThreads;
	  configdat.bCLSparse = cfg->bCLSparse; 
	  configdat.nCLDeviceNum = cfg->nCLDeviceNum;
	  configdat.nCLPlatformNum = cfg->nCLPlatformNum;
	  configdat.bCLInteropGL = cfg->bCLInteropGL;
	  for(i = 0; i < 8; i++) {
	    if(cfg->sDeviceName[i] != NULL) free(cfg->sDeviceName[i]);
	  }
#endif
	  free(cfg);
	}
	ver = fm7_ver;
	ApplyCfg();
	/*
	 * VMヴァージョンが違ったら強制リセット
	 */
	if(ver != fm7_ver){
		system_reset();
	}
	/*
	 * ここにアイコン変更入れる
	 */

	/*
	 * 終了処理
	 */
	UnlockVM();

	if(self != NULL) {
	  AG_WindowHide(self->wid.window);
	  AG_ObjectDetach(self);
	}
}
int flash_pre_init(void)
{
	uint32_t reset_flags = system_get_reset_flags();
	uint32_t prot_flags = flash_get_protect();
	int need_reset = 0;

	/*
	 * If we have already jumped between images, an earlier image could
	 * have applied write protection. Nothing additional needs to be done.
	 */
	if (reset_flags & RESET_FLAG_SYSJUMP)
		return EC_SUCCESS;

	if (prot_flags & EC_FLASH_PROTECT_GPIO_ASSERTED) {
		if ((prot_flags & EC_FLASH_PROTECT_RO_AT_BOOT) &&
		    !(prot_flags & EC_FLASH_PROTECT_RO_NOW)) {
			/*
			 * Pstate wants RO protected at boot, but the write
			 * protect register wasn't set to protect it.  Force an
			 * update to the write protect register and reboot so
			 * it takes effect.
			 */
			flash_protect_at_boot(FLASH_WP_RO);
			need_reset = 1;
		}

		if (prot_flags & EC_FLASH_PROTECT_ERROR_INCONSISTENT) {
			/*
			 * Write protect register was in an inconsistent state.
			 * Set it back to a good state and reboot.
			 */
			flash_protect_at_boot(
				(prot_flags & EC_FLASH_PROTECT_RO_AT_BOOT) ?
				FLASH_WP_RO : FLASH_WP_NONE);
			need_reset = 1;
		}
	} else if (prot_flags & (EC_FLASH_PROTECT_RO_NOW |
				 EC_FLASH_PROTECT_ERROR_INCONSISTENT)) {
		/*
		 * Write protect pin unasserted but some section is
		 * protected. Drop it and reboot.
		 */
		unlock(STM32_FLASH_PECR_OPT_LOCK);
		write_optb_wrp(0);
		lock();
		need_reset = 1;
	}

	if (need_reset)
		system_reset(SYSTEM_RESET_HARD | SYSTEM_RESET_PRESERVE_FLAGS);

	return EC_SUCCESS;
}
    void reloadrom(int size, char *name)
    {
        LOG_DBG("reloadrom(%d, %s)\n", size, current_rom);
        bool hotswap = config.hot_swap && cart.romsize;

        /* load ROM file */
        LOG_DBG("cart.romsize = %d\n", size);
        cart.romsize = size;
        LOG_DBG("load_rom(%s)\n", name);
        load_rom(name);

        LOG_DBG("hotswap: %d\n", hotswap);
        LOG_DBG("region detect: %d\n", config.region_detect);
        if(hotswap)
        {
            cart_hw_init();
            cart_hw_reset(1);
        }

        /* initialize audio back-end */
        /* 60hz video mode requires synchronization with Video Interrupt.    */
        /* Framerate is 59.94 fps in interlaced/progressive modes, ~59.825 fps in non-interlaced mode */
        LOG_DBG("vdp_pal: %d\n", vdp_pal);
        LOG_DBG("config.tv_mode: %d\n", config.tv_mode);
        LOG_DBG("config.render: %d\n", config.render);
        float framerate;
        if (vdp_pal)
        {
            framerate = 49.82;
        }
        else
        {
            framerate = ((config.tv_mode == 0) || (config.tv_mode == 2)) ? (1000000.0/16715.0) : 60.0;
        }

        LOG_DBG("audio_init(%d, %f)\n", SAMPLERATE_48_3KHZ, framerate);
        LOG_DBG("framerate: %f\n", framerate);
        audio_init(SAMPLERATE_48_3KHZ, framerate);

        /* System Power ON */
        LOG_DBG("system_init()\n");
        system_init();
        LOG_DBG("system_reset()\n");
        system_reset();

        /* load SRAM */
        LoadSRAM();

        //FIXME: TODO
        /* load State */
    }
Example #22
0
/*
 *  This is for NOT having enough hibernate (more precisely, the stand-by mode)
 *  wake-up source pin. STM32L100 supports 3 wake-up source pins:
 *
 *     WKUP1 (PA0)  -- used for ACOK_PMU
 *     WKUP2 (PC13) -- used for LID_OPEN
 *     WKUP3 (PE6)  -- cannot be used due to IC package.
 *
 *  However, we need the power button as a wake-up source as well and there is
 *  no available pin for us (we don't want to move the ACOK_PMU pin).
 *
 *  Fortunately, the STM32L is low-power enough so that we don't need the
 *  super-low-power mode. So, we fake this hibernate mode and accept the
 *  following wake-up source.
 *
 *     RTC alarm  (faked as well).
 *     Power button
 *     Lid open
 *     AC detected
 *
 *  The original issue is here: crosbug.com/p/25435.
 */
void __enter_hibernate(uint32_t seconds, uint32_t microseconds)
{
	int i;
	fake_hibernate = 1;

#ifdef CONFIG_POWER_COMMON
	/*
	 * A quick hack to stop annoying messages from charger task.
	 *
	 * When the battery is under 3%, the power task would call
	 * power_off() to shutdown AP. However, the power_off() would
	 * notify the HOOK_CHIPSET_SHUTDOWN, where the last hook is
	 * charge_shutdown() and it hibernates the power task (infinite
	 * loop -- not real CPU hibernate mode). Unfortunately, the
	 * charger task is still running. It keeps generating annoying
	 * log message.
	 *
	 * Thus, the hack is to set the power state machine (before we
	 * enter infinite loop) so that the charger task thinks the AP
	 * is off and stops generating messages.
	 */
	power_set_state(POWER_G3);
#endif

	/*
	 * Change keyboard outputs to high-Z to reduce power draw.
	 * We don't need corresponding code to change them back,
	 * because fake hibernate is always exited with a reboot.
	 *
	 * A little hacky to do this here.
	 */
	for (i = GPIO_KB_OUT00; i < GPIO_KB_OUT00 + KEYBOARD_COLS; i++)
		gpio_set_flags(i, GPIO_INPUT);

	ccprints("fake hibernate. waits for power button/lid/RTC/AC");
	cflush();

	if (seconds || microseconds) {
		if (seconds)
			sleep(seconds);
		if (microseconds)
			usleep(microseconds);
	} else {
		while (1)
			task_wait_event(-1);
	}

	ccprints("fake RTC alarm fires. resets EC");
	cflush();
	system_reset(SYSTEM_RESET_HARD);
}
Example #23
0
int OnQuickloadOk(const void *browser, const void *path)
{
  int first_time = 0;
  if (!GAME_LOADED)
    first_time = 1;

  if (!load_rom((char*)path))
  {
    pspUiAlert("Error loading cartridge");
    return 0;
  }

  SET_AS_CURRENT_GAME((char*)path);
  pl_file_get_parent_directory((const char*)path,
                               GamePath,
                               sizeof(GamePath));

  /* Reset selected state */
  SaveStateGallery.Menu.selected = NULL;

  if (first_time)
  {
    pspUiFlashMessage("Initializing for first-time use\nPlease wait...");
    audio_init(SOUND_FREQUENCY, 0);
    system_init();
    //error_init();
    system_reset();
  }
  else{
    system_init();
    system_reset();
    audio_reset();
  }
  pl_rewind_reset(&Rewinder);

  ResumeEmulation = 1;
  return 1;
}
Example #24
0
/*-------------------------------------------------------------------*/
int ARCH_DEP(common_load_begin) (int cpu, int clear)
{
    REGS *regs;

    /* Save the original architecture mode for later */
    orig_arch_mode = sysblk.dummyregs.arch_mode = sysblk.arch_mode;
#if defined(OPTION_FISHIO)
    ios_arch_mode = sysblk.arch_mode;
#endif // defined(OPTION_FISHIO)

    /* Perform system-reset-normal or system-reset-clear function */
    if (ARCH_DEP(system_reset(cpu,clear)) != 0)
        return -1;
    regs = sysblk.regs[cpu];

    if (sysblk.arch_mode == ARCH_900)
    {
        /* Switch architecture mode to ESA390 mode for z/Arch IPL */
        sysblk.arch_mode = ARCH_390;
        /* Capture the z/Arch PSW if this is a Load-normal IPL */
        if (!clear)
            captured_zpsw = regs->psw;
    }

    /* Load-clear does a clear-reset (which does an initial-cpu-reset)
       on all cpus in the configuration, but Load-normal does an initial-
       cpu-reset only for the IPL CPU and a regular cpu-reset for all
       other CPUs in the configuration. Thus if the above system_reset
       call did a system-normal-reset for us, then we need to manually
       do a clear-reset (initial-cpu-reset) on the IPL CPU...
    */
    if (!clear)
    {
        /* Perform initial reset on the IPL CPU */
        if (ARCH_DEP(initial_cpu_reset) (regs) != 0)
            return -1;
        /* Save our captured-z/Arch-PSW if this is a Load-normal IPL
           since the initial_cpu_reset call cleared it to zero. */
        if (orig_arch_mode == ARCH_900)
            regs->captured_zpsw = captured_zpsw;
    }

    /* The actual IPL (load) now begins... */
    regs->loadstate = 1;

    return 0;
} /* end function common_load_begin */
Example #25
0
//
// parse BLE events
//
void onBleEvent(bleDevice * p_ble, BLE_EVENT_T evt) {
	switch(evt) {
	case BLE_ON_CONNECTED:
		p_ble->onConnected();
		break;

	case BLE_ON_DISCONNECTED:
		p_ble->onDisconnected();
		beacon_mode = beacon_mode_normal;
		advertising_init(beacon_mode);
		break;

	case BLE_ON_TIMEOUT:
		system_reset();
		break;
	}
}
void host_command_received(struct host_cmd_handler_args *args)
{
	/*
	 * TODO(crosbug.com/p/23806): should warn if we already think we're in
	 * a command.
	 */

	/*
	 * If this is the reboot command, reboot immediately.  This gives the
	 * host processor a way to unwedge the EC even if it's busy with some
	 * other command.
	 */
	if (args->command == EC_CMD_REBOOT) {
		system_reset(SYSTEM_RESET_HARD);
		/* Reset should never return; if it does, post an error */
		args->result = EC_RES_ERROR;
	}

#ifdef CONFIG_AP_HANG_DETECT
	/* If hang detection is enabled, check stop on host command */
	hang_detect_stop_on_host_command();
#endif

	if (args->result) {
		; /* driver has signalled an error, respond now */
#ifdef CONFIG_HOST_COMMAND_STATUS
	} else if (args->command == EC_CMD_GET_COMMS_STATUS) {
		args->result = host_command_process(args);
#endif
	} else {
		/* Save the command */
		pending_args = args;

		/* Wake up the task to handle the command */
		task_set_event(TASK_ID_HOSTCMD, TASK_EVENT_CMD_PENDING, 0);
		return;
	}

	/*
	 * TODO (crosbug.com/p/29315): This is typically running in interrupt
	 * context, so it woud be better not to send the response here, and to
	 * let the host command task send the response.
	 */
	/* Send the response now */
	host_send_response(args);
}
Example #27
0
/*******************************************
  Restart emulation when loading a new game 
********************************************/
void reloadrom(void)
{
  /* Cartridge "Hot Swap" support (make sure system has already been inited once and use cartridges) */
  if ((config.hot_swap == 3) && ((system_hw != SYSTEM_MCD) || scd.cartridge.boot))
  {
    /* Only initialize cartridge hardware */
    if ((system_hw & SYSTEM_PBC) == SYSTEM_MD)
    {
      /* 16-bit cartridge */
      md_cart_init();
      md_cart_reset(1);
    }
    else
    {
      /* 8-bit cartridge */
      sms_cart_init();
      sms_cart_reset();
    }
  }

  /* Disc Swap support (automatically enabled if CD tray is open) */
  else if ((system_hw != SYSTEM_MCD) || (cdd.status != CD_OPEN))
  {
    /* Initialize audio emulation */
    interlaced = 0;
    audio_init(SAMPLERATE_48KHZ, get_framerate());
     
    /* Switch virtual system on */
    system_init();
    system_reset();

    /* Allow hot swap */
    config.hot_swap |= 2;
  }

  /* Auto-Load Backup RAM */
  slot_autoload(0,config.s_device);
            
  /* Auto-Load State */
  slot_autoload(config.s_default,config.s_device);

  /* Load Cheat file */
  CheatLoad();
}
Example #28
0
void SDLKbdInterface::OnRelease(void *eventh)
{
    int            i;
    SDL_Event *event = (SDL_Event *)eventh;

    Uint32 modifier = (Uint32)event->key.keysym.mod;
    Uint32 code = (Uint32)event->key.keysym.sym;
//    Uint8 scan = event->key.keysym.scancode;
    struct XM7KeyCode *p = KeyCodeTable2;

    for (i = 0; i < 255; i++) {
    	if (p[i].code == 0xffff)   break;
    	if (code == p[i].code){
    			PushKeyData(p[i].pushCode, 0x00); /* Break */
    			break;
    		}
    }

	/*
	 * F11押下の場合はマウスキャプチャフラグを反転させてモード切り替え->メニューにする
	 */
//	if ((code == MouseCapture.sym) && (modifier == MouseCapture.mod)) {
	if (code == MouseCapture.sym) {
    	if(bMouseCaptureFlag) {
			bMouseCaptureFlag = FALSE;
			SDL_WM_GrabInput(SDL_GRAB_OFF);
		} else {
			bMouseCaptureFlag = TRUE;
			SDL_WM_GrabInput(SDL_GRAB_ON);
		}

    }

	/*
	 * F12押下の場合はVMリセット
	 */
//	if ((code == ResetKey.sym) && (modifier == ResetKey.mod)) {
	if (code == ResetKey.sym) {
		LockVM();
		system_reset();
		UnlockVM();
    }
}
Example #29
0
void board_hibernate(void)
{
	CPRINTS("Triggering PMIC shutdown.");
	uart_flush_output();

	/* Trigger PMIC shutdown. */
	if (i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x49, 0x01)) {
		/*
		 * If we can't tell the PMIC to shutdown, instead reset
		 * and don't start the AP. Hopefully we'll be able to
		 * communicate with the PMIC next time.
		 */
		CPRINTS("PMIC i2c failed.");
		system_reset(SYSTEM_RESET_LEAVE_AP_OFF);
	}

	/* Await shutdown. */
	while (1)
		;
}
Example #30
0
int OnMenuOk(const void *uimenu, const void* sel_item)
{
  if (uimenu == &ControlUiMenu)
  {
    /* Save to MS */
    if (SaveButtonConfig())
      pspUiAlert("Changes saved");
    else
      pspUiAlert("ERROR: Changes not saved");
  }
  else if (uimenu == &SystemUiMenu)
  {
    switch (((const pl_menu_item*)sel_item)->id)
    {
    case SYSTEM_RESET:

      /* Reset system */
      if (pspUiConfirm("Reset the system?"))
      {
        ResumeEmulation = 1;
        system_reset();
        pl_rewind_reset(&Rewinder);
        return 1;
      }
      break;

    case SYSTEM_SCRNSHOT:

      /* Save screenshot */
      if (!pl_util_save_image_seq(ScreenshotPath,
                                  pl_file_get_filename(CURRENT_GAME),
                                  Screen))
        pspUiAlert("ERROR: Screenshot not saved");
      else
        pspUiAlert("Screenshot saved successfully");
      break;
    }
  }

  return 0;
}