sim_events_poll (void *data) { event_queue *queue = data; /* just re-schedule in 1000 million ticks time */ event_queue_schedule (queue, SIM_EVENTS_POLL_RATE, sim_events_poll, queue); sim_io_poll_quit (); }
schedule_hardware_interrupt_delivery(cpu *processor) { interrupts *ints = cpu_interrupts(processor); if (ints->delivery_scheduled == NULL) { ints->delivery_scheduled = event_queue_schedule(psim_event_queue(cpu_system(processor)), 0, deliver_hardware_interrupt, processor); } }
event_queue_init(event_queue *queue) { event_entry *event; /* drain the interrupt queue */ { #if defined(HAVE_SIGPROCMASK) && defined(SIG_SETMASK) sigset_t old_mask; sigset_t new_mask; sigfillset(&new_mask); /*-LOCK-*/ sigprocmask(SIG_SETMASK, &new_mask, &old_mask); #endif event = queue->held; while (event != NULL) { event_entry *dead = event; event = event->next; free(dead); } queue->held = NULL; queue->held_end = &queue->held; #if defined(HAVE_SIGPROCMASK) && defined(SIG_SETMASK) /*-UNLOCK-*/ sigprocmask(SIG_SETMASK, &old_mask, NULL); #endif } /* drain the normal queue */ event = queue->queue; while (event != NULL) { event_entry *dead = event; event = event->next; free(dead); } queue->queue = NULL; /* wind time back to one */ queue->processing = 0; queue->time_of_event = 0; queue->time_from_event = -1; /* schedule our initial counter event */ event_queue_schedule (queue, 0, sim_events_poll, queue); }
psim_init(psim *system) { int cpu_nr; /* scrub the monitor */ mon_init(system->monitor, system->nr_cpus); /* trash any pending events */ event_queue_init(system->events); /* if needed, schedule a halt event. FIXME - In the future this will be replaced by a more generic change to psim_command(). A new command `schedule NNN halt' being added. */ if (tree_find_property(system->devices, "/openprom/options/max-iterations")) { event_queue_schedule(system->events, tree_find_integer_property(system->devices, "/openprom/options/max-iterations") - 2, psim_max_iterations_exceeded, system); } /* scrub all the cpus */ for (cpu_nr = 0; cpu_nr < system->nr_cpus; cpu_nr++) cpu_init(system->processors[cpu_nr]); /* init all the devices (which updates the cpus) */ tree_init(system->devices, system); /* and the emulation (which needs an initialized device tree) */ os_emul_init(system->os_emulation, system->nr_cpus); /* now sync each cpu against the initialized state of its registers */ for (cpu_nr = 0; cpu_nr < system->nr_cpus; cpu_nr++) { cpu *processor = system->processors[cpu_nr]; cpu_synchronize_context(processor, cpu_get_program_counter(processor)); cpu_page_tlb_invalidate_all(processor); } /* force loop to start with first cpu */ system->last_cpu = -1; }