void USBLinkTreeWidget::reloadFilebrowser()
{
    bool is_false = false;
    if(!doing_dirlist.compare_exchange_strong(is_false, true))
        usblink_queue_reset(); // The treeWidget is cleared, so references to items get invalid -> Get rid of them!

    this->clear();
    usblink_queue_dirlist("/", usblink_dirlist_callback, this);
}
Example #2
0
void MainWindow::connectUSB()
{
    if(usblink_connected)
        usblink_queue_reset();
    else
        usblink_connect();

    usblinkChanged(false);
}
Example #3
0
void EmuThread::reset()
{
    usblink_queue_reset();

    cpu_events |= EVENT_RESET;
}
Example #4
0
bool emu_start(unsigned int port_gdb, unsigned int port_rdbg, const char *snapshot_file)
{
    gui_busy_raii gui_busy;

    if(snapshot_file)
    {
        // Open snapshot
        size_t snapshot_size = gzip_filesize(snapshot_file);
        if(snapshot_size < sizeof(emu_snapshot))
            return false;

        FILE *fp = fopen_utf8(snapshot_file, "rb");
        if(!fp)
            return false;

        int dupfd = dup(fileno(fp));
        fclose(fp);
        fp = nullptr;

        // gzdopen takes ownership of the fd
        gzFile gzf = gzdopen(dupfd, "r");
        if(!gzf)
        {
            close(dupfd);
            return false;
        }

        auto snapshot = (struct emu_snapshot *) malloc(snapshot_size);
        if(!snapshot)
        {
            gzclose(gzf);
            return false;
        }

        if((size_t) gzread(gzf, snapshot, snapshot_size) != snapshot_size)
        {
            gzclose(gzf);
            free(snapshot);
            return false;
        }
        gzclose(gzf);

        //sched_reset();
        sched.items[SCHED_THROTTLE].clock = CLOCK_27M;
        sched.items[SCHED_THROTTLE].proc = throttle_interval_event;

        // TODO: Max length
        path_boot1 = std::string(snapshot->path_boot1);
        path_flash = std::string(snapshot->path_flash);

        // TODO: Pass snapshot_size to flash_resume to avoid reading after the buffer

        // Resume components
        uint32_t sdram_size;
        if(snapshot->sig != SNAPSHOT_SIG
                || snapshot->version != SNAPSHOT_VER
                || !flash_resume(snapshot)
                || !flash_read_settings(&sdram_size, &product, &features, &asic_user_flags)
                || !cpu_resume(snapshot)
                || !memory_resume(snapshot)
                || !sched_resume(snapshot))
        {
            emu_cleanup();
            free(snapshot);
            return false;
        }
        free(snapshot);
    }
    else
    {
        if (!flash_open(path_flash.c_str()))
                return false;

        uint32_t sdram_size;
        flash_read_settings(&sdram_size, &product, &features, &asic_user_flags);

        flash_set_bootorder(boot_order);

        if(!memory_initialize(sdram_size))
        {
            emu_cleanup();
            return false;
        }
    }

    if(debug_on_start)
        cpu_events |= EVENT_DEBUG_STEP;

    uint8_t *rom = mem_areas[0].ptr;
    memset(rom, -1, 0x80000);
    for (int i = 0x00000; i < 0x80000; i += 4)
        RAM_FLAGS(&rom[i]) = RF_READ_ONLY;

    /* Load the ROM */
    FILE *f = fopen_utf8(path_boot1.c_str(), "rb");
    if (!f) {
        gui_perror(path_boot1.c_str());
        emu_cleanup();
        return false;
    }
    (void)fread(rom, 1, 0x80000, f);
    fclose(f);

#ifndef NO_TRANSLATION
    if(!translate_init())
    {
        gui_debug_printf("Could not init JIT, disabling translation.\n");
        do_translate = false;
    }
#endif

    addr_cache_init();

    throttle_timer_on();

    if(port_gdb)
        gdbstub_init(port_gdb);

    if(port_rdbg)
        rdebug_bind(port_rdbg);

    usblink_queue_reset();

    if(!snapshot_file)
        emu_reset();

    return true;
}