void hypervisor_call(guest* vm, uint32_t imm16) { rf_elr_hyp_write(rf_elr_hyp_read() - 4); switch(imm16) { //monitor print vm case 0x1: printmi(vm->id, d_hypervisor_call, "hypervisor call, monitor print vm"); monitor_print(&vm->mon); break; //monitor print sys case 0x2: printmi(vm->id, d_hypervisor_call, "hypervisor call, monitor print sys"); monitor_print(&sys_monitor); break; case 0x3: printmi(vm->id, d_hypervisor_call, "hypervisor call, monitor print all"); printm(d_monitor, "================MON_SYS==================="); monitor_print(&sys_monitor); printm(d_monitor, "================MON_VM===================="); monitor_print(&vm->mon); printm(d_monitor, "=========================================="); break; default: printm(d_hypervisor_call, "error hypervisor call, imm = %d", imm16); break; } }
void monitor_save(adv_conf* context, const adv_monitor* monitor) { char buffer[1024]; monitor_print(buffer, sizeof(buffer), monitor); conf_string_set(context, "", "device_video_clock", buffer); }
void monitor_printf(char* fmt, ...) { __builtin_va_list ap; __builtin_va_start(ap, fmt); uint32_t val; char* str; if (fmt == NULL) { return; } while(*fmt != 0) { if (*fmt == '%') { fmt++; switch(*fmt++) { case 'd': // Integer val = __builtin_va_arg(ap, uint32_t); monitor_print_dec(val); break; case 'X': case 'x': val = __builtin_va_arg(ap, uint32_t); monitor_print_hex(val); break; case 's': str = __builtin_va_arg(ap, char*); monitor_print(str); break; } } else {
void monitor_print_hex(uint32_t val) { char* map = "0123456789ABCDEF"; int i; monitor_print("0x"); for(i = sizeof(val) * 2 - 1; i >= 0; i--) { monitor_put(map[(val >> (i * 4)) & 0xF]); } }
void isr_handler(registers_t regs) { monitor_print("recieved interrupt: "); monitor_print_dec(regs.int_no); monitor_put('\n'); }
int os_main(int argc, char* argv[]) { adv_crtc_container selected; adv_crtc_container_iterator i; const char* opt_rc; adv_bool opt_log; adv_bool opt_logsync; int j; adv_error res; char* section_map[1]; char buffer[1024]; opt_rc = 0; opt_log = 0; opt_logsync = 0; the_advance = advance_mame; the_sound_flag = 1; the_config = conf_init(); if (os_init(the_config)!=0) { target_err("Error initializing the OS support.\n"); goto err_conf; } video_reg(the_config, 1); monitor_register(the_config); crtc_container_register(the_config); generate_interpolate_register(the_config); gtf_register(the_config); inputb_reg(the_config, 1); inputb_reg_driver_all(the_config); /* MSDOS requires a special driver sub set */ #ifndef __MSDOS__ video_reg_driver_all(the_config); #endif if (conf_input_args_load(the_config, 1, "", &argc, argv, error_callback, 0) != 0) goto err_os; for(j=1;j<argc;++j) { if (target_option_compare(argv[j], "rc") && j+1<argc) { opt_rc = argv[++j]; } else if (target_option_compare(argv[j], "log")) { opt_log = 1; } else if (target_option_compare(argv[j], "logsync")) { opt_logsync = 1; } else if (target_option_compare(argv[j], "nosound")) { the_sound_flag = 0; } else if (target_option_compare(argv[j], "advmamev")) { the_advance = advance_mame; } else if (target_option_compare(argv[j], "advmessv")) { the_advance = advance_mess; } else if (target_option_compare(argv[j], "advpacv")) { the_advance = advance_pac; } else if (target_option_compare(argv[j], "advmenuv")) { the_advance = advance_menu; #ifdef __MSDOS__ } else if (target_option_compare(argv[j], "vgav")) { the_advance = advance_vga; } else if (target_option_compare(argv[j], "vbev")) { the_advance = advance_vbe; #endif #ifdef __WIN32__ } else if (target_option_compare(argv[j], "videowv")) { the_advance = advance_videow; #endif } else { target_err("Unknown option %s\n", argv[j]); goto err; } } #ifdef __MSDOS__ /* WARNING the MSDOS drivers are registered after the command line management. */ /* It implyes that you cannot specify any driver options on the command line */ msdos_rut(); if (the_advance == advance_vga) { if (the_advance_vga_active) { target_err("The AdvanceVGA utility is active. Disable it before running vgav.\n"); goto err; } video_reg_driver(the_config, &video_vgaline_driver); } else if (the_advance == advance_vbe) { if (the_advance_vbe_active) { target_err("The AdvanceVBE utility is active. Disable it before running vbev.\n"); goto err; } video_reg_driver(the_config, &video_vbeline_driver); video_reg_driver(the_config, &video_vgaline_driver); /* for the text modes */ } else { video_reg_driver_all(the_config); } #endif if (!opt_rc) { switch (the_advance) { case advance_vbe : opt_rc = "vbe.rc"; break; case advance_vga : opt_rc = "vga.rc"; break; case advance_menu : opt_rc = file_config_file_home("advmenu.rc"); break; case advance_mame : opt_rc = file_config_file_home("advmame.rc"); break; case advance_mess : opt_rc = file_config_file_home("advmess.rc"); break; case advance_pac : opt_rc = file_config_file_home("advpac.rc"); break; case advance_videow : opt_rc = file_config_file_home("videow.rc"); break; default : opt_rc = "advv.rc"; break; } } if (access(opt_rc, R_OK)!=0) { target_err("Configuration file %s not found.\n", opt_rc); goto err_os; } if (conf_input_file_load_adv(the_config, 0, opt_rc, opt_rc, 1, 1, STANDARD, sizeof(STANDARD)/sizeof(STANDARD[0]), error_callback, 0) != 0) goto err_os; if (opt_log || opt_logsync) { const char* log = "advv.log"; remove(log); log_init(log, opt_logsync); } log_std(("v: %s %s\n", __DATE__, __TIME__)); section_map[0] = ""; conf_section_set(the_config, section_map, 1); if (video_load(the_config, "") != 0) { target_err("Error loading the video options from the configuration file %s.\n", opt_rc); target_err("%s\n", error_get()); goto err_os; } if (inputb_load(the_config) != 0) { target_err("%s\n", error_get()); goto err_os; } /* NOTE: After this command all the target_err() string must */ /* have \n\r at the end to ensure correct newline in graphics mode. */ if (os_inner_init("AdvanceVIDEO") != 0) { goto err_os; } if (adv_video_init() != 0) { target_err("%s\n\r", error_get()); troubleshotting(); goto err_os_inner; } if (video_blit_init() != 0) { target_err("%s\n\r", error_get()); goto err_video; } if (the_advance != advance_vbe && the_advance != advance_vga) { if ((video_mode_generate_driver_flags(VIDEO_DRIVER_FLAGS_MODE_GRAPH_MASK, 0) & VIDEO_DRIVER_FLAGS_PROGRAMMABLE_CLOCK) == 0) { target_err("No active video driver is able to program your video board.\n\r"); troubleshotting(); goto err_blit; } } if (inputb_init() != 0) { target_err("%s\n\r", error_get()); goto err_blit; } if (monitor_load(the_config, &the_monitor) != 0) { target_err("Error loading the clock options from the configuration file %s.\n\r", opt_rc); target_err("%s\n\r", error_get()); goto err_input; } monitor_print(buffer, sizeof(buffer), &the_monitor); log_std(("v: clock %s\n", buffer)); /* load generate_linear config */ res = generate_interpolate_load(the_config, &the_interpolate); if (res<0) { target_err("Error loading the format options from the configuration file %s.\n\r", opt_rc); target_err("%s\n\r", error_get()); goto err_input; } if (res>0) { generate_default_vga(&the_interpolate.map[0].gen); the_interpolate.map[0].hclock = 31500; the_interpolate.mac = 1; } /* load generate_linear config */ res = gtf_load(the_config, &the_gtf); if (res<0) { target_err("Error loading the gtf options from the configuration file %s.\n\r", opt_rc); target_err("%s\n\r", error_get()); goto err_input; } if (res>0) { gtf_default_vga(&the_gtf); } /* all mode */ crtc_container_init(&selected); /* insert modes */ crtc_container_insert_default_all(&selected); /* sort */ crtc_container_init(&the_modes); for(crtc_container_iterator_begin(&i, &selected);!crtc_container_iterator_is_end(&i);crtc_container_iterator_next(&i)) { adv_crtc* crtc = crtc_container_iterator_get(&i); crtc_container_insert_sort(&the_modes, crtc, crtc_compare); } crtc_container_done(&selected); /* load selected */ crtc_container_init(&selected); if (crtc_container_load(the_config, &selected) != 0) { target_err("%s\n\r", error_get()); goto err_input; } /* union set */ for(crtc_container_iterator_begin(&i, &selected);!crtc_container_iterator_is_end(&i);crtc_container_iterator_next(&i)) { adv_crtc* crtc = crtc_container_iterator_get(&i); adv_bool has = crtc_container_has(&the_modes, crtc, crtc_compare) != 0; if (has) crtc_container_remove(&the_modes, crtc_select_by_compare, crtc); crtc->user_flags |= MODE_FLAGS_USER_BIT0; crtc_container_insert_sort(&the_modes, crtc, crtc_compare); } crtc_container_done(&selected); the_modes_modified = 0; if (text_init(&the_modes, &the_monitor) != 0) { goto err_input; } if (inputb_enable(0) != 0) { goto err_text; } sound_signal(); menu_run(); log_std(("v: shutdown\n")); inputb_disable(); text_done(); crtc_container_done(&the_modes); inputb_done(); video_blit_done(); adv_video_done(); os_inner_done(); log_std(("v: the end\n")); if (opt_log || opt_logsync) { log_done(); } os_done(); conf_save(the_config, 0, 0, error_callback, 0); conf_done(the_config); return EXIT_SUCCESS; err_text: text_done(); err_input: inputb_done(); err_blit: video_blit_done(); err_video: adv_video_done(); err_os_inner: os_inner_done(); err_os: if (opt_log || opt_logsync) { log_done(); } os_done(); err_conf: conf_done(the_config); err: return EXIT_FAILURE; }