Пример #1
0
void kernel_main(unsigned long magic,
		 unsigned long addr)
{
  multiboot_info_t *mbi;

  if (magic != MULTIBOOT_BOOTLOADER_MAGIC)
    return;

  mbi = (multiboot_info_t*)addr;

  /* kernel init
   */
  serial_init(DEBUG_SERIAL_PORT,
	      DEBUG_SERIAL_SPEED,
	      UART_8BITS_WORD,
	      UART_NO_PARITY,
	      UART_1_STOP_BIT);
  cls();

  cpu_cli();
  printf("[x] interrupts disabled\n");

  gdt_initialize();
  printf("[x] gdt initialized\n");

  idt_initialize();
  printf("[x] idt initialized\n");

  breakpoint_initialize();

#if defined(USE_APIC)
  apic_initialize();
  serial_printl("[x] apic initialized\n");
#else
  pic_initialize();
  serial_printl("[x] pic initialized\n");
#endif /* USE_APIC */

  /* initialize the kernel
   */
  {
    kernel_init(mbi);
  }

  /* memory initialization
   */
  {
    phys_init(mbi);
    phys_debug();
/*     vm_init(); */
/*     unit_test_vm(); */
/*     cpu_hlt(); */
  }

#if defined(USE_PCI)
  pci_initialize();
  pci_list();
#endif

  cpu_sti();

#if defined(USE_TASK)
 {
   /* subsystems
    */
   event_initialize();
   sched_initialize();
   task_initialize();

   /* tasks
    */
   idle_initialize();
   muksh_initialize();
   net_initialize();

/*    task_test(); */

   /* start scheduling
    */
   sched_start();
 }
#endif

 /* endless loop
  */
 serial_printl("[?] kernel loop\n");
 while (1)
   {
     serial_printl("k");
     cpu_hlt();
   }
}
Пример #2
0
/*********************************************************************************************************
* emulation thread - runs the core
*/
m64p_error main_run(void)
{
    VILimit = (float) GetVILimit();
    VILimitMilliseconds = (double) 1000.0/VILimit; 

    /* take the r4300 emulator mode from the config file at this point and cache it in a global variable */
    r4300emu = ConfigGetParamInt(g_CoreConfig, "R4300Emulator");

    /* set some other core parameters based on the config file values */
    savestates_set_autoinc_slot(ConfigGetParamBool(g_CoreConfig, "AutoStateSlotIncrement"));
    savestates_select_slot(ConfigGetParamInt(g_CoreConfig, "CurrentStateSlot"));
    no_compiled_jump = ConfigGetParamBool(g_CoreConfig, "NoCompiledJump");

    /* set up the SDL key repeat and event filter to catch keyboard/joystick commands for the core */
    event_initialize();

    // initialize memory, and do byte-swapping if it's not been done yet
    if (g_MemHasBeenBSwapped == 0)
    {
        init_memory(1);
        g_MemHasBeenBSwapped = 1;
    }
    else
    {
        init_memory(0);
    }

    // Attach rom to plugins
    if (!romOpen_gfx())
    {
        free_memory(); SDL_Quit(); return M64ERR_PLUGIN_FAIL;
    }
    if (!romOpen_audio())
    {
        romClosed_gfx(); free_memory(); SDL_Quit(); return M64ERR_PLUGIN_FAIL;
    }
    if (!romOpen_input())
    {
        romClosed_audio(); romClosed_gfx(); free_memory(); SDL_Quit(); return M64ERR_PLUGIN_FAIL;
    }

    if (ConfigGetParamBool(g_CoreConfig, "OnScreenDisplay"))
    {
        // init on-screen display
        int width = 640, height = 480;
        readScreen(NULL, &width, &height, 0); // read screen to get width and height
        osd_init(width, height);
    }

    // setup rendering callback from video plugin to the core, for screenshots and On-Screen-Display
    setRenderingCallback(video_plugin_render_callback);

#ifdef WITH_LIRC
    lircStart();
#endif // WITH_LIRC

#ifdef DBG
    if (ConfigGetParamBool(g_CoreConfig, "EnableDebugger"))
        init_debugger();
#endif

    /* Startup message on the OSD */
    osd_new_message(OSD_MIDDLE_CENTER, "Mupen64Plus Started...");

    g_EmulatorRunning = 1;
    StateChanged(M64CORE_EMU_STATE, M64EMU_RUNNING);

    /* call r4300 CPU core and run the game */
    r4300_reset_hard();
    r4300_reset_soft();
    r4300_execute();

#ifdef WITH_LIRC
    lircStop();
#endif // WITH_LIRC

#ifdef DBG
    if (g_DebuggerActive)
        destroy_debugger();
#endif

    if (ConfigGetParamBool(g_CoreConfig, "OnScreenDisplay"))
    {
        osd_exit();
    }

    romClosed_RSP();
    romClosed_input();
    romClosed_audio();
    romClosed_gfx();
    free_memory();

    // clean up
    g_EmulatorRunning = 0;
    StateChanged(M64CORE_EMU_STATE, M64EMU_STOPPED);

    SDL_Quit();

    return M64ERR_SUCCESS;
}
Пример #3
0
/*********************************************************************************************************
* emulation thread - runs the core
*/
m64p_error main_run(void)
{
	DebugMessage(M64MSG_STATUS, "Main Run!");
    VILimit = (float) GetVILimit();
    VILimitMilliseconds = (double) 1000.0/VILimit; 

    /* take the r4300 emulator mode from the config file at this point and cache it in a global variable */
    r4300emu = ConfigGetParamInt(g_CoreConfig, "R4300Emulator");

    /* set some other core parameters based on the config file values */
    savestates_set_autoinc_slot(ConfigGetParamBool(g_CoreConfig, "AutoStateSlotIncrement"));
    savestates_select_slot(ConfigGetParamInt(g_CoreConfig, "CurrentStateSlot"));
    no_compiled_jump = ConfigGetParamBool(g_CoreConfig, "NoCompiledJump");

    /* set up the SDL key repeat and event filter to catch keyboard/joystick commands for the core */
    event_initialize();

    // initialize memory, and do byte-swapping if it's not been done yet
    if (g_MemHasBeenBSwapped == 0)
    {
        init_memory(1);
        g_MemHasBeenBSwapped = 1;
    }
    else
    {
        init_memory(0);
    }

    // Attach rom to plugins
    if (!romOpen_gfx())
    {
        free_memory(); return M64ERR_PLUGIN_FAIL;
    }
    DebugMessage(M64MSG_STATUS, "Graphics Plugin Opened!");
    if (!romOpen_audio())
    {
        romClosed_gfx(); free_memory(); return M64ERR_PLUGIN_FAIL;
    }
    DebugMessage(M64MSG_STATUS, "Audio Plugin Opened!");
    if (!romOpen_input())
    {
        romClosed_audio(); romClosed_gfx(); free_memory(); return M64ERR_PLUGIN_FAIL;
    }
    DebugMessage(M64MSG_STATUS, "Input Plugin Opened!");
    printf("Plugins opened!\n");fflush(stdout);

#ifdef WITH_LIRC
    lircStart();
#endif // WITH_LIRC

#ifdef DBG
    if (ConfigGetParamBool(g_CoreConfig, "EnableDebugger"))
        init_debugger();
#endif

    //PumpEvents();


    g_EmulatorRunning = 1;
    StateChanged(M64CORE_EMU_STATE, M64EMU_RUNNING);
    DebugMessage(M64MSG_STATUS, "Starting to reset r4300!");fflush(stdout);
    /* call r4300 CPU core and run the game */
    r4300_reset_hard();
    r4300_reset_soft();
    DebugMessage(M64MSG_STATUS, "About to execute!");
    fflush(stdout);
    r4300_execute();

#ifdef WITH_LIRC
    lircStop();
#endif // WITH_LIRC

#ifdef DBG
    if (g_DebuggerActive)
        destroy_debugger();
#endif

    romClosed_RSP();
    romClosed_input();
    romClosed_audio();
    romClosed_gfx();
    free_memory();

    // clean up
    g_EmulatorRunning = 0;
    StateChanged(M64CORE_EMU_STATE, M64EMU_STOPPED);

    //PDL_Quit();
    SDL_Quit();

    return M64ERR_SUCCESS;
}