Esempio n. 1
0
/**
 * Get the system going.
 *
 * Prepare all system-specific structures and initialise BP and APs. Enter root domain and continue there.
 *
 * TODO: relate Pistachio SMP startup routines here.
 */
extern "C" void kernel_startup()
{
    // No dynamic memory allocation here yet, global objects not constructed either.
    run_global_ctors();

    global_descriptor_table_t gdt;
    kconsole << "Created GDT." << endl;
    interrupt_descriptor_table_t::instance().install();
    kconsole << "Created IDT." << endl;

    // Grab the bootinfo page and discover where is our bootimage.
    bootinfo_t* bi = new(bootinfo_t::ADDRESS) bootinfo_t;

    address_t start, end;
    const char* name;
    if (!bi->get_module(1, start, end, name))
    {
        PANIC("Bootimage not found!");
    }

    bootimage_t bootimage(name, start, end);

    parse_cmdline(bi);
    prepare_infopage(); // <-- init domain info page
    check_cpu_features(); // cmdline might affect used CPU feats? (i.e. noacpi flag)
    
    // TODO: CREATE INITIAL MEMORY MAPPINGS PROPERLY HERE
    // TEMPORARY: just map all mem 0..min(16Mb, RAMtop) to 1-1 mapping? for simplicity
//    int ramtop = 16*MiB;
    bi->append_vmap(0, 0, 16*MiB);//min(16*MiB, ramtop));

    timer_v1::closure_t* timer = init_timer();
    timer->enable(0); // enable timer interrupts
    kconsole << "Timer interrupt enabled." << endl;
    x86_cpu_t::enable_fpu();
    kconsole << "FPU enabled." << endl;

//    kconsole << WHITE << "...in the living memory of V2_OS" << LIGHTGRAY << endl;

    root_domain_t root_dom(bootimage);

//     kconsole << "+ root_domain entry @ 0x" << root_dom.entry() << endl;

    // Create an execution context and activate it.
    continuation_t::gpregs_t gpregs;
    gpregs.esp = read_stack_pointer();
    gpregs.eax = 0;
    gpregs.ebx = 0;
    gpregs.eflags = 0x03002; /* Flags for root domain: interrupts disabled, IOPL=3 (program can use IO ports) */
    new_context.set_gpregs(gpregs);
    new_context.set_entry(root_dom.entry());//FIXME: depends on gpregs being set before this call!
    new_context.activate(); // we have a liftoff!

    /* Never reached */
    PANIC("root domain returned!");
}
Esempio n. 2
0
static void BootUpProblems()
{
    s32 ret2;

    // load main font from file, or default to built-in font
    fontSystem = new FreeTypeGX();
    fontSystem->loadFont(NULL, font_ttf, font_ttf_size, 0);
    fontSystem->setCompatibilityMode(FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_PASSCLR | FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_NONE);

    GuiImageData bootimageData(gxlogo_png);
    GuiImage bootimage(&bootimageData);
    GuiText boottext(NULL, 20, (GXColor) {255, 255, 255, 255}
    );
    boottext.SetPosition(200, 240-1.2*bootimage.GetHeight()/2+250);
    bootimage.SetPosition(320-1.2*bootimage.GetWidth()/2, 240-1.2*bootimage.GetHeight()/2);
    bootimage.SetScale(1.2);

    GuiImageData usbimageData(usbport_png);
    GuiImage usbimage(&usbimageData);
    usbimage.SetPosition(400,300);
    usbimage.SetScale(.7);
    usbimage.SetAlpha(200);

    time_t curtime;
    time_t endtime = time(0) + 30;
    do
    {
        /*ret2 = IOS_ReloadIOSsafe(249);
        if (ret2 < 0) {
            ret2 = IOS_ReloadIOSsafe(222);
            SDCard_Init();
            load_ehc_module();
            SDCard_deInit();
            if(ret2 <0) {
                boottext.SetText("ERROR: cIOS could not be loaded!");
                bootimage.Draw();
                boottext.Draw();
                Menu_Render();
        sleep(5);
        SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
        }
        }*/
        USBDevice_deInit();
        USBDevice_Init();
        ret2 = WBFS_Init(WBFS_DEVICE_USB);
        if (ret2 >= 0)
        {
            boottext.SetText("Loading...");
            bootimage.Draw();
            boottext.Draw();
            Menu_Render();
            break;
        }
        curtime = time(0);
        boottext.SetTextf("Waiting for your slow USB Device: %i secs...", int(endtime-curtime));
        while(curtime == time(0))
        {
            boottext.Draw();
            bootimage.Draw();
            if (endtime-curtime<15)usbimage.Draw();
            Menu_Render();
        }
    } while((endtime-time(0)) > 0);

    /*if(ret2 < 0) {
        boottext.SetText("ERROR: USB device could not be loaded!");
        usbimage.Draw();
        bootimage.Draw();
        boottext.Draw();
        Menu_Render();
        SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
    }*/

    ///delete font to load up custom if set
    if(fontSystem)
    {
        delete fontSystem;
        fontSystem = NULL;
    }
}