Commit bb0c6722b6606ad34da75d093d95a9bdfe42bc98

Authored by bellard
1 parent 979a54fb

reset and shutdown support - PCI is now the default


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@937 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 2 changed files with 81 additions and 5 deletions
... ... @@ -127,7 +127,7 @@ SerialState *serial_console;
127 127 QEMUTimer *gui_timer;
128 128 int vm_running;
129 129 int audio_enabled = 0;
130   -int pci_enabled = 0;
  130 +int pci_enabled = 1;
131 131 int prep_enabled = 0;
132 132 int rtc_utc = 1;
133 133 int cirrus_vga_enabled = 0;
... ... @@ -1819,6 +1819,62 @@ void vm_stop(int reason)
1819 1819 }
1820 1820 }
1821 1821  
  1822 +/* reset/shutdown handler */
  1823 +
  1824 +typedef struct QEMUResetEntry {
  1825 + QEMUResetHandler *func;
  1826 + void *opaque;
  1827 + struct QEMUResetEntry *next;
  1828 +} QEMUResetEntry;
  1829 +
  1830 +static QEMUResetEntry *first_reset_entry;
  1831 +static int reset_requested;
  1832 +static int shutdown_requested;
  1833 +
  1834 +void qemu_register_reset(QEMUResetHandler *func, void *opaque)
  1835 +{
  1836 + QEMUResetEntry **pre, *re;
  1837 +
  1838 + pre = &first_reset_entry;
  1839 + while (*pre != NULL)
  1840 + pre = &(*pre)->next;
  1841 + re = qemu_mallocz(sizeof(QEMUResetEntry));
  1842 + re->func = func;
  1843 + re->opaque = opaque;
  1844 + re->next = NULL;
  1845 + *pre = re;
  1846 +}
  1847 +
  1848 +void qemu_system_reset(void)
  1849 +{
  1850 + QEMUResetEntry *re;
  1851 +
  1852 + /* reset all devices */
  1853 + for(re = first_reset_entry; re != NULL; re = re->next) {
  1854 + re->func(re->opaque);
  1855 + }
  1856 +}
  1857 +
  1858 +void qemu_system_reset_request(void)
  1859 +{
  1860 + reset_requested = 1;
  1861 + cpu_interrupt(cpu_single_env, CPU_INTERRUPT_EXIT);
  1862 +}
  1863 +
  1864 +void qemu_system_shutdown_request(void)
  1865 +{
  1866 + shutdown_requested = 1;
  1867 + cpu_interrupt(cpu_single_env, CPU_INTERRUPT_EXIT);
  1868 +}
  1869 +
  1870 +static void main_cpu_reset(void *opaque)
  1871 +{
  1872 +#ifdef TARGET_I386
  1873 + CPUState *env = opaque;
  1874 + cpu_reset(env);
  1875 +#endif
  1876 +}
  1877 +
1822 1878 int main_loop(void)
1823 1879 {
1824 1880 #ifndef _WIN32
... ... @@ -1833,10 +1889,15 @@ int main_loop(void)
1833 1889 for(;;) {
1834 1890 if (vm_running) {
1835 1891 ret = cpu_exec(env);
1836   - if (reset_requested) {
  1892 + if (shutdown_requested) {
1837 1893 ret = EXCP_INTERRUPT;
1838 1894 break;
1839 1895 }
  1896 + if (reset_requested) {
  1897 + reset_requested = 0;
  1898 + qemu_system_reset();
  1899 + ret = EXCP_INTERRUPT;
  1900 + }
1840 1901 if (ret == EXCP_DEBUG) {
1841 1902 vm_stop(EXCP_DEBUG);
1842 1903 }
... ... @@ -1967,6 +2028,9 @@ void help(void)
1967 2028 "-nographic disable graphical output and redirect serial I/Os to console\n"
1968 2029 "-enable-audio enable audio support\n"
1969 2030 "-localtime set the real time clock to local time [default=utc]\n"
  2031 +#ifdef TARGET_PPC
  2032 + "-prep Simulate a PREP system (default is PowerMAC)\n"
  2033 +#endif
1970 2034 "\n"
1971 2035 "Network options:\n"
1972 2036 "-nics n simulate 'n' network cards [default=1]\n"
... ... @@ -1993,7 +2057,9 @@ void help(void)
1993 2057 #ifdef USE_CODE_COPY
1994 2058 "-no-code-copy disable code copy acceleration\n"
1995 2059 #endif
1996   -
  2060 +#ifdef TARGET_I386
  2061 + "-isa simulate an ISA-only system (default is PCI system)\n"
  2062 +#endif
1997 2063 "\n"
1998 2064 "During emulation, use C-a h to get terminal commands:\n",
1999 2065 #ifdef CONFIG_SOFTMMU
... ... @@ -2052,6 +2118,7 @@ enum {
2052 2118 QEMU_OPTION_L,
2053 2119 QEMU_OPTION_no_code_copy,
2054 2120 QEMU_OPTION_pci,
  2121 + QEMU_OPTION_isa,
2055 2122 QEMU_OPTION_prep,
2056 2123 QEMU_OPTION_localtime,
2057 2124 QEMU_OPTION_cirrusvga,
... ... @@ -2103,6 +2170,7 @@ const QEMUOption qemu_options[] = {
2103 2170 { "prep", 0, QEMU_OPTION_prep },
2104 2171 #endif
2105 2172 { "localtime", 0, QEMU_OPTION_localtime },
  2173 + { "isa", 0, QEMU_OPTION_isa },
2106 2174  
2107 2175 /* temporary options */
2108 2176 { "pci", 0, QEMU_OPTION_pci },
... ... @@ -2380,6 +2448,9 @@ int main(int argc, char **argv)
2380 2448 case QEMU_OPTION_pci:
2381 2449 pci_enabled = 1;
2382 2450 break;
  2451 + case QEMU_OPTION_isa:
  2452 + pci_enabled = 0;
  2453 + break;
2383 2454 case QEMU_OPTION_prep:
2384 2455 prep_enabled = 1;
2385 2456 break;
... ... @@ -2562,6 +2633,7 @@ int main(int argc, char **argv)
2562 2633 register_savevm("timer", 0, 1, timer_save, timer_load, env);
2563 2634 register_savevm("cpu", 0, 1, cpu_save, cpu_load, env);
2564 2635 register_savevm("ram", 0, 1, ram_save, ram_load, NULL);
  2636 + qemu_register_reset(main_cpu_reset, global_env);
2565 2637  
2566 2638 init_ioports();
2567 2639 cpu_calibrate_ticks();
... ...
... ... @@ -205,8 +205,6 @@ static inline uint32_t le32_to_cpupu(const uint32_t *p)
205 205 #endif
206 206  
207 207 /* vl.c */
208   -extern int reset_requested;
209   -
210 208 uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c);
211 209  
212 210 void hw_error(const char *fmt, ...);
... ... @@ -229,6 +227,12 @@ void qemu_del_vm_stop_handler(VMStopHandler *cb, void *opaque);
229 227 void vm_start(void);
230 228 void vm_stop(int reason);
231 229  
  230 +typedef void QEMUResetHandler(void *opaque);
  231 +
  232 +void qemu_register_reset(QEMUResetHandler *func, void *opaque);
  233 +void qemu_system_reset_request(void);
  234 +void qemu_system_shutdown_request(void);
  235 +
232 236 extern int audio_enabled;
233 237 extern int ram_size;
234 238 extern int bios_size;
... ...