timetrav::timetrav() { m_shortgamename = "timetrav"; memset(m_cpumem, 0, CPU_MEM_SIZE); struct cpudef cpu; memset(&cpu, 0, sizeof(struct cpudef)); cpu.type = CPU_I88; cpu.hz = TIMETRAV_CPU_HZ; cpu.irq_period[0] = 0; cpu.irq_period[1] = 0; cpu.nmi_period = (1000.0 / 59.94); cpu.initial_pc = 0xFFFF0; cpu.must_copy_context = false; cpu.mem = m_cpumem; add_cpu(&cpu); // add this cpu to the list (it will be our only one) m_disc_fps = 29.97; // m_game_type = GAME_TIMETRAV; m_game_uses_video_overlay = true; m_video_overlay_width = 320; // default values we start with for video overlay m_video_overlay_height = 240; m_palette_color_count = 256; m_video_overlay_count = 1; m_overlay_size_is_dynamic = true; // this game does dynamically change its overlay size static struct rom_def g_timetrav_roms[] = { { "TT061891.BIN", NULL, &m_cpumem[0xc0000], 0x40000, 0x00000000 }, { NULL } }; m_rom_list = g_timetrav_roms; }
mcputest::mcputest() { struct cpudef cpu; m_shortgamename = "mcputest"; memset(&cpu, 0, sizeof(struct cpudef)); // clear struct for safety purposes cpu.type = CPU_Z80; cpu.hz = 4000000; // cpu speed is irrelevant cpu.irq_period[0] = 1000.0; // 1 IRQ every second cpu.nmi_period = 500.0; // 2 NMIs per second cpu.initial_pc = 0; cpu.must_copy_context = true; cpu.mem = m_cpumem; add_cpu(&cpu); // add this cpu to the list m_game_uses_video_overlay = false; memset(&cpu, 0, sizeof(struct cpudef)); // for safety purposes cpu.type = CPU_Z80; cpu.hz = 5000000; // cpu speed is irrelevant cpu.irq_period[0] = 2000.0; // 1 IRQ every second cpu.nmi_period = 1000.0; // 2 NMIs per second cpu.initial_pc = 0; cpu.must_copy_context = true; cpu.mem = m_cpumem2; add_cpu(&cpu); // add this cpu to the list const static struct rom_def multicputest_roms[] = { { "prog1.bin", "cputest", &m_cpumem[0], 113, 0xAEFCA341 }, { "prog2.bin", "cputest", &m_cpumem2[0], 113, 0xC6C8CE9 }, { NULL } }; m_rom_list = multicputest_roms; }
int run(void) { xmlDocPtr doc; xmlNodePtr node; int ct = STACKCT_OPT(OUTPUT); char **output = (char **) &STACKLST_OPT(OUTPUT); GString *log; int i; int color; int highest_color = STAT_GREEN; char buf[24]; extern int forever; uw_setproctitle("sleeping"); for (i=0; i < OPT_VALUE_INTERVAL; i++) { // wait some minutes sleep(1); if (!forever) { return(0); } } uw_setproctitle("getting system statistics"); get_stats(); doc = UpwatchXmlDoc("result", NULL); xmlSetDocCompressMode(doc, OPT_VALUE_COMPRESS); // do the sysstat node = (xmlNodePtr) newnode(doc, "sysstat"); add_loadavg(node); add_cpu(node); add_paging(node); add_blockio(node); add_swap(node); add_memory(node); add_systemp(node); add_sysstat_info(node); color = xmlGetPropInt(node, "color"); if (color > highest_color) highest_color = color; #if USE_XMBMON|| defined (__OpenBSD__) if (OPT_VALUE_HWSTATS ) { // do the hwstat get_hwstats(); node = (xmlNodePtr) newnode(doc, "hwstat"); add_hwstat(node); color = xmlGetPropInt(node, "color"); if (color > highest_color) highest_color = color; } #endif if (OPT_VALUE_LOCALCHECKS ) { // do the local checks color = do_local((xmlNodePtr) doc); if (color > highest_color) highest_color = color; } #if HAVE_LIBPCRE // do the errlog node = (xmlNodePtr) newnode(doc, "errlog"); log = check_logs(&color); if (color > highest_color) highest_color = color; sprintf(buf, "%u", color); xmlSetProp(node, "color", buf); if (log) { if (log->str && strlen(log->str) > 0) { xmlNewTextChild(node, NULL, "info", log->str); } g_string_free(log, TRUE); } #endif // do the diskfree uw_setproctitle("checking diskspace"); node = (xmlNodePtr) newnode(doc, "diskfree"); add_diskfree_info(node); color = xmlGetPropInt(node, "color"); if (color > highest_color) highest_color = color; if (HAVE_OPT(HPQUEUE) && (highest_color != prv_highest_color)) { // if status changed, it needs to be sent immediately. So drop into // the high priority queue. Else just drop in the normal queue where // uw_send in batched mode will pick it up later spool_result(OPT_ARG(SPOOLDIR), OPT_ARG(HPQUEUE), doc, NULL); } else { for (i=0; i < ct; i++) { spool_result(OPT_ARG(SPOOLDIR), output[i], doc, NULL); } } prv_highest_color = highest_color; // remember for next time xmlFreeDoc(doc); return 0; }
int dm_run(int argc, char *argv[]) { int c, error, err; int max_vcpus, mptgen; struct vmctx *ctx; size_t memsize; int option_idx = 0; progname = basename(argv[0]); guest_ncpus = 1; memsize = 256 * MB; mptgen = 1; if (signal(SIGHUP, sig_handler_term) == SIG_ERR) fprintf(stderr, "cannot register handler for SIGHUP\n"); if (signal(SIGINT, sig_handler_term) == SIG_ERR) fprintf(stderr, "cannot register handler for SIGINT\n"); while ((c = getopt_long(argc, argv, optstr, long_options, &option_idx)) != -1) { switch (c) { case 'A': acpi = 1; break; case 'p': if (pincpu_parse(optarg) != 0) { errx(EX_USAGE, "invalid vcpu pinning configuration '%s'", optarg); } break; case 'c': dm_strtoi(optarg, NULL, 0, &guest_ncpus); break; case 'E': if (acrn_parse_elf(optarg) != 0) exit(1); else break; break; case 'i': ioc_parse(optarg); break; case 'l': if (lpc_device_parse(optarg) != 0) { errx(EX_USAGE, "invalid lpc device configuration '%s'", optarg); } break; case 's': if (pci_parse_slot(optarg) != 0) exit(1); else break; case 'm': error = vm_parse_memsize(optarg, &memsize); if (error) errx(EX_USAGE, "invalid memsize '%s'", optarg); break; case 'U': guest_uuid_str = optarg; break; case 'W': virtio_msix = 0; break; case 'Y': mptgen = 0; break; case 'k': if (acrn_parse_kernel(optarg) != 0) exit(1); else break; case 'r': if (acrn_parse_ramdisk(optarg) != 0) exit(1); else break; case 'B': if (acrn_parse_bootargs(optarg) != 0) exit(1); else break; break; case 'G': if (acrn_parse_gvtargs(optarg) != 0) { errx(EX_USAGE, "invalid GVT param %s", optarg); exit(1); } break; case 'v': print_version(); break; case CMD_OPT_VSBL: if (high_bios_size() == 0 && acrn_parse_vsbl(optarg) != 0) { errx(EX_USAGE, "invalid vsbl param %s", optarg); exit(1); } break; case CMD_OPT_OVMF: if (!vsbl_file_name && acrn_parse_ovmf(optarg) != 0) { errx(EX_USAGE, "invalid ovmf param %s", optarg); exit(1); } break; case CMD_OPT_PART_INFO: if (acrn_parse_guest_part_info(optarg) != 0) { errx(EX_USAGE, "invalid guest partition info param %s", optarg); exit(1); } break; case CMD_OPT_TRUSTY_ENABLE: trusty_enabled = 1; break; case CMD_OPT_VIRTIO_POLL_ENABLE: if (acrn_parse_virtio_poll_interval(optarg) != 0) { errx(EX_USAGE, "invalid virtio poll interval %s", optarg); exit(1); } break; case CMD_OPT_MAC_SEED: strncpy(mac_seed_str, optarg, sizeof(mac_seed_str)); mac_seed_str[sizeof(mac_seed_str) - 1] = '\0'; mac_seed = mac_seed_str; break; case CMD_OPT_PTDEV_NO_RESET: ptdev_no_reset(true); break; case CMD_OPT_DEBUGEXIT: debugexit_enabled = true; break; case CMD_OPT_LAPIC_PT: lapic_pt = true; break; case CMD_OPT_VTPM2: if (acrn_parse_vtpm2(optarg) != 0) { errx(EX_USAGE, "invalid vtpm2 param %s", optarg); exit(1); } break; case CMD_OPT_INTR_MONITOR: if (acrn_parse_intr_monitor(optarg) != 0) { errx(EX_USAGE, "invalid intr-monitor params %s", optarg); exit(1); } break; case 'h': usage(0); default: usage(1); } } argc -= optind; argv += optind; if (argc != 1) usage(1); if (!check_hugetlb_support()) { fprintf(stderr, "check_hugetlb_support failed\n"); exit(1); } vmname = argv[0]; for (;;) { ctx = vm_create(vmname, (unsigned long)vhm_req_buf); if (!ctx) { perror("vm_open"); exit(1); } if (guest_ncpus < 1) { fprintf(stderr, "Invalid guest vCPUs (%d)\n", guest_ncpus); goto fail; } max_vcpus = num_vcpus_allowed(ctx); if (guest_ncpus > max_vcpus) { fprintf(stderr, "%d vCPUs requested but %d available\n", guest_ncpus, max_vcpus); goto fail; } err = vm_setup_memory(ctx, memsize); if (err) { fprintf(stderr, "Unable to setup memory (%d)\n", errno); goto fail; } err = mevent_init(); if (err) { fprintf(stderr, "Unable to initialize mevent (%d)\n", errno); goto mevent_fail; } if (vm_init_vdevs(ctx) < 0) { fprintf(stderr, "Unable to init vdev (%d)\n", errno); goto dev_fail; } /* * build the guest tables, MP etc. */ if (mptgen) { error = mptable_build(ctx, guest_ncpus); if (error) { goto vm_fail; } } error = smbios_build(ctx); if (error) goto vm_fail; if (acpi) { error = acpi_build(ctx, guest_ncpus); if (error) goto vm_fail; } error = acrn_sw_load(ctx); if (error) goto vm_fail; /* * Change the proc title to include the VM name. */ /*setproctitle("%s", vmname);*/ /* * Add CPU 0 */ error = add_cpu(ctx, guest_ncpus); if (error) goto vm_fail; /* Make a copy for ctx */ _ctx = ctx; /* * Head off to the main event dispatch loop */ mevent_dispatch(); vm_pause(ctx); delete_cpu(ctx, BSP); if (vm_get_suspend_mode() != VM_SUSPEND_FULL_RESET) break; vm_deinit_vdevs(ctx); mevent_deinit(); vm_unsetup_memory(ctx); vm_destroy(ctx); _ctx = 0; vm_set_suspend_mode(VM_SUSPEND_NONE); } vm_fail: vm_deinit_vdevs(ctx); dev_fail: mevent_deinit(); mevent_fail: vm_unsetup_memory(ctx); fail: vm_destroy(ctx); exit(0); }