static CPU_EXECUTE( dsp32c ) { dsp32_state *cpustate = get_safe_token(device); /* skip if halted */ if ((cpustate->pcr & PCR_RESET) == 0) return cycles; /* count cycles and interrupt cycles */ cpustate->icount = cycles; /* update buffered accumulator values */ cpustate->abufcycle[0] += cpustate->icount; cpustate->abufcycle[1] += cpustate->icount; cpustate->abufcycle[2] += cpustate->icount; cpustate->abufcycle[3] += cpustate->icount; /* handle interrupts */ check_irqs(cpustate); while (cpustate->icount > 0) execute_one(cpustate); /* normalize buffered accumulator values */ cpustate->abufcycle[0] -= cpustate->icount; cpustate->abufcycle[1] -= cpustate->icount; cpustate->abufcycle[2] -= cpustate->icount; cpustate->abufcycle[3] -= cpustate->icount; return cycles - cpustate->icount; }
void dsp32c_device::execute_run() { // skip if halted if ((m_pcr & PCR_RESET) == 0) { m_icount = 0; return; } // update buffered accumulator values m_abufcycle[0] += m_icount; m_abufcycle[1] += m_icount; m_abufcycle[2] += m_icount; m_abufcycle[3] += m_icount; // handle interrupts check_irqs(); while (m_icount > 0) execute_one(); // normalize buffered accumulator values m_abufcycle[0] -= m_icount; m_abufcycle[1] -= m_icount; m_abufcycle[2] -= m_icount; m_abufcycle[3] -= m_icount; }
static void dsp56k_set_context(void *src) { /* copy the context */ if (src) dsp56k = *(dsp56k_regs *)src; memory_set_opbase(PC); /* check for IRQs */ check_irqs(); }
void lc8670_cpu_device::execute_run() { if (m_clock_changed) { change_clock_source(); return; } do { check_irqs(); debugger_instruction_hook(this, m_pc); int cycles = 0; m_ppc = m_pc; if (REG_PCON & HALT_MODE) { // in HALT state the timers are still updated cycles = 1; } else { // instruction fetch m_op = fetch(); int op_idx = decode_op(m_op); // execute the instruction cycles = (this->*s_opcode_table[op_idx])(); } // update the instruction counter m_icount -= cycles; } while (m_icount > 0 && !m_clock_changed); }
void main_loop (void) { int activity=0, sleep_now=0, total_unused=0; int sleep_battery=0; int prev_ac_line_status=0; time_t nowtime, oldtime=0; apm_info ai; double loadavg[1]; if (use_events) { pthread_t emthread; pthread_create(&emthread, NULL, eventMonitor, NULL); } while (1) { activity=0; if (use_events) { pthread_mutex_lock(&condition_mutex); pthread_cond_signal(&condition_cond); pthread_mutex_unlock(&condition_mutex); } if (use_acpi) { acpi_read(1, &ai); } #ifdef HAL else if (use_simplehal) { simplehal_read(1, &ai); } #endif else { apm_read(&ai); } if (min_batt != -1 && ai.ac_line_status != 1 && ai.battery_percentage < min_batt && ai.battery_status != BATTERY_STATUS_ABSENT) { sleep_battery = 1; } if (sleep_battery && ! require_unused_and_battery) { syslog(LOG_NOTICE, "battery level %d%% is below %d%%; forcing hibernation", ai.battery_percentage, min_batt); if (system(hibernate_command) != 0) syslog(LOG_ERR, "%s failed", hibernate_command); /* This counts as activity; to prevent double sleeps. */ if (debug) printf("sleepd: activity: just woke up\n"); activity=1; oldtime=0; sleep_battery=0; } /* Rest is only needed if sleeping on inactivity. */ if (! max_unused && ! ac_max_unused) { sleep(sleep_time); continue; } if (autoprobe || have_irqs) { activity=check_irqs(activity, autoprobe); } if (use_net) { activity=check_net(activity); } if ((max_loadavg != 0) && (getloadavg(loadavg, 1) == 1) && (loadavg[0] >= max_loadavg)) { /* If the load average is too high */ if (debug) printf("sleepd: activity: load average %f\n", loadavg[0]); activity=1; } if (use_utmp == 1) { total_unused=check_utmp(total_unused); } if (ai.ac_line_status != prev_ac_line_status) { /* AC plug/unplug counts as activity. */ if (debug) printf("sleepd: activity: AC status change\n"); activity=1; } prev_ac_line_status=ai.ac_line_status; sleep(sleep_time); if (use_events) { pthread_mutex_lock(&activity_mutex); if (eventData.emactivity == 1) { if (debug) printf("sleepd: activity: keyboard/mouse events\n"); activity=1; } pthread_mutex_unlock(&activity_mutex); } if (activity) { total_unused = 0; } else { total_unused += sleep_time; if (ai.ac_line_status == 1) { /* On wall power. */ if (ac_max_unused > 0) { sleep_now = total_unused >= ac_max_unused; } } else if (max_unused > 0) { sleep_now = total_unused >= max_unused; } if (sleep_now && ! no_sleep && ! require_unused_and_battery) { syslog(LOG_NOTICE, "system inactive for %ds; forcing sleep", total_unused); if (system(sleep_command) != 0) syslog(LOG_ERR, "%s failed", sleep_command); total_unused=0; oldtime=0; sleep_now=0; } else if (sleep_now && ! no_sleep && sleep_battery) { syslog(LOG_NOTICE, "system inactive for %ds and battery level %d%% is below %d%%; forcing hibernaton", total_unused, ai.battery_percentage, min_batt); if (system(hibernate_command) != 0) syslog(LOG_ERR, "%s failed", hibernate_command); total_unused=0; oldtime=0; sleep_now=0; sleep_battery=0; } } /* * Keep track of how long it's been since we were last * here. If it was much longer than sleep_time, the system * was probably suspended, or this program was, (or the * kernel is thrashing :-), so clear idle counter. */ nowtime=time(NULL); /* The 1 is a necessary fudge factor. */ if (oldtime && nowtime - sleep_time > oldtime + 1) { no_sleep=0; /* reset, since they must have put it to sleep */ writecontrol(no_sleep); syslog(LOG_NOTICE, "%i sec sleep; resetting timer", (int)(nowtime - oldtime)); total_unused=0; } oldtime=nowtime; } }