Commit b1f9be3157368392b62d5c4213413d5adddd015b

Authored by j_mayer
1 parent 6c041c54

Add -cpu option for linux user emulation.

Only usable for PowerPC and ARM for now.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2496 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 23 additions and 11 deletions
linux-user/main.c
... ... @@ -1537,13 +1537,14 @@ void cpu_loop(CPUM68KState *env)
1537 1537 void usage(void)
1538 1538 {
1539 1539 printf("qemu-" TARGET_ARCH " version " QEMU_VERSION ", Copyright (c) 2003-2007 Fabrice Bellard\n"
1540   - "usage: qemu-" TARGET_ARCH " [-h] [-g] [-d opts] [-L path] [-s size] program [arguments...]\n"
  1540 + "usage: qemu-" TARGET_ARCH " [-h] [-g] [-d opts] [-L path] [-s size] [-cpu model] program [arguments...]\n"
1541 1541 "Linux CPU emulator (compiled for %s emulation)\n"
1542 1542 "\n"
1543 1543 "-h print this help\n"
1544 1544 "-g port wait gdb connection to port\n"
1545 1545 "-L path set the elf interpreter prefix (default=%s)\n"
1546 1546 "-s size set the stack size in bytes (default=%ld)\n"
  1547 + "-cpu model select CPU (-cpu ? for list)\n"
1547 1548 "\n"
1548 1549 "debug options:\n"
1549 1550 #ifdef USE_CODE_COPY
... ... @@ -1567,6 +1568,7 @@ TaskState *first_task_state;
1567 1568 int main(int argc, char **argv)
1568 1569 {
1569 1570 const char *filename;
  1571 + const char *cpu_model;
1570 1572 struct target_pt_regs regs1, *regs = &regs1;
1571 1573 struct image_info info1, *info = &info1;
1572 1574 TaskState ts1, *ts = &ts1;
... ... @@ -1581,6 +1583,7 @@ int main(int argc, char **argv)
1581 1583 /* init debug */
1582 1584 cpu_set_log_filename(DEBUG_LOGFILE);
1583 1585  
  1586 + cpu_model = NULL;
1584 1587 optind = 1;
1585 1588 for(;;) {
1586 1589 if (optind >= argc)
... ... @@ -1631,6 +1634,18 @@ int main(int argc, char **argv)
1631 1634 gdbstub_port = atoi(argv[optind++]);
1632 1635 } else if (!strcmp(r, "r")) {
1633 1636 qemu_uname_release = argv[optind++];
  1637 + } else if (!strcmp(r, "cpu")) {
  1638 + cpu_model = argv[optind++];
  1639 + if (strcmp(cpu_model, "?") == 0) {
  1640 +#if defined(TARGET_PPC)
  1641 + ppc_cpu_list(stdout, &fprintf);
  1642 +#elif defined(TARGET_ARM)
  1643 + arm_cpu_list();
  1644 +#elif defined(TARGET_MIPS)
  1645 + mips_cpu_list(stdout, &fprintf);
  1646 +#endif
  1647 + exit(1);
  1648 + }
1634 1649 } else
1635 1650 #ifdef USE_CODE_COPY
1636 1651 if (!strcmp(r, "no-code-copy")) {
... ... @@ -1756,7 +1771,9 @@ int main(int argc, char **argv)
1756 1771 #elif defined(TARGET_ARM)
1757 1772 {
1758 1773 int i;
1759   - cpu_arm_set_model(env, "arm926");
  1774 + if (cpu_model == NULL)
  1775 + cpu_model = "arm926";
  1776 + cpu_arm_set_model(env, cpu_model);
1760 1777 cpsr_write(env, regs->uregs[16], 0xffffffff);
1761 1778 for(i = 0; i < 16; i++) {
1762 1779 env->regs[i] = regs->uregs[i];
... ... @@ -1783,15 +1800,9 @@ int main(int argc, char **argv)
1783 1800 int i;
1784 1801  
1785 1802 /* Choose and initialise CPU */
1786   - /* XXX: CPU model (or PVR) should be provided on command line */
1787   - // ppc_find_by_name("750gx", &def);
1788   - // ppc_find_by_name("750fx", &def);
1789   - // ppc_find_by_name("750p", &def);
1790   - ppc_find_by_name("750", &def);
1791   - // ppc_find_by_name("G3", &def);
1792   - // ppc_find_by_name("604r", &def);
1793   - // ppc_find_by_name("604e", &def);
1794   - // ppc_find_by_name("604", &def);
  1803 + if (cpu_model == NULL)
  1804 + cpu_model = "750";
  1805 + ppc_find_by_name(cpu_model, &def);
1795 1806 if (def == NULL) {
1796 1807 cpu_abort(env,
1797 1808 "Unable to find PowerPC CPU definition\n");
... ... @@ -1840,6 +1851,7 @@ int main(int argc, char **argv)
1840 1851 {
1841 1852 int i;
1842 1853  
  1854 + /* XXX: set CPU model */
1843 1855 for(i = 0; i < 32; i++) {
1844 1856 env->gpr[i] = regs->regs[i];
1845 1857 }
... ...