コード例 #1
0
ファイル: driver-hashfast.c プロジェクト: uraymeiviar/cgminer
static bool hfa_initialise(struct cgpu_info *hashfast)
{
    int err;

    if (hashfast->usbinfo.nodev)
        return false;

    hfa_clear_readbuf(hashfast);

    err = usb_transfer(hashfast, 0, 9, 1, 0, C_ATMEL_RESET);
    if (!err)
        err = usb_transfer(hashfast, 0x21, 0x22, 0, 0, C_ATMEL_OPEN);
    if (!err) {
        uint32_t buf[2];

        /* Magic sequence to reset device only really needed for windows
         * but harmless on linux. */
        buf[0] = 0x80250000;
        buf[1] = 0x00000800;
        err = usb_transfer_data(hashfast, 0x21, 0x20, 0x0000, 0, buf,
                                7, C_ATMEL_INIT);
    }
    if (err < 0) {
        applog(LOG_INFO, "HFA %d: Failed to open with error %s",
               hashfast->device_id, libusb_error_name(err));
    }
    /* Must have transmitted init sequence sized buffer */
    return (err == 7);
}
コード例 #2
0
ファイル: driver-hashfast.c プロジェクト: uraymeiviar/cgminer
static bool hfa_detect_common(struct cgpu_info *hashfast)
{
    struct hashfast_info *info;
    bool ret;

    info = calloc(sizeof(struct hashfast_info), 1);
    if (!info)
        quit(1, "Failed to calloc hashfast_info in hfa_detect_common");
    hashfast->device_data = info;
    /* hashfast_reset should fill in details for info */
    ret = hfa_reset(hashfast, info);
    if (!ret) {
        hfa_send_shutdown(hashfast);
        hfa_clear_readbuf(hashfast);
        free(info);
        hashfast->device_data = NULL;
        return false;
    }

    // The per-die status array
    info->die_status = calloc(info->asic_count, sizeof(struct hf_g1_die_data));
    if (unlikely(!(info->die_status)))
        quit(1, "Failed to calloc die_status");

    // The per-die statistics array
    info->die_statistics = calloc(info->asic_count, sizeof(struct hf_long_statistics));
    if (unlikely(!(info->die_statistics)))
        quit(1, "Failed to calloc die_statistics");

    info->works = calloc(sizeof(struct work *), info->num_sequence);
    if (!info->works)
        quit(1, "Failed to calloc info works in hfa_detect_common");

    return true;
}
コード例 #3
0
static void hfa_shutdown(struct thr_info *thr)
{
	struct cgpu_info *hashfast = thr->cgpu;
	struct hashfast_info *info = hashfast->device_data;

	hfa_send_shutdown(hashfast);
	pthread_join(info->read_thr, NULL);
	hfa_free_all_work(info);
	hfa_clear_readbuf(hashfast);
	free(info->works);
	free(info->die_statistics);
	free(info->die_status);
	free(info);
}
コード例 #4
0
ファイル: driver-hashfast.c プロジェクト: uraymeiviar/cgminer
static void hfa_shutdown(struct thr_info *thr)
{
    struct cgpu_info *hashfast = thr->cgpu;
    struct hashfast_info *info = hashfast->device_data;

    hfa_send_shutdown(hashfast);
    pthread_join(info->read_thr, NULL);
    hfa_free_all_work(info);
    hfa_clear_readbuf(hashfast);
    free(info->works);
    free(info->die_statistics);
    free(info->die_status);
    /* Don't free info here since it will be accessed by statline before
     * if a device is removed. */
}