コード例 #1
0
ファイル: restrack.c プロジェクト: i-willh/imame4all
void *auto_malloc_file_line(running_machine *machine, size_t size, const char *file, int line)
{
    void *result = pool_malloc_file_line(current_pool(), size, file, line);
#ifdef MAME_DEBUG
    rand_memory(result, size);
#endif
    return result;
}
コード例 #2
0
ファイル: restrack.c プロジェクト: broftkd/historic-mame
void *auto_realloc_file_line(void *ptr, size_t size, const char *file, int line)
{
	object_pool *pool = current_pool();
	if (ptr != NULL)
	{
		int tag = resource_tracking_tag;
		for (; tag > 0; tag--)
		{
			pool = pools[tag - 1];
			if (pool_object_exists(pool, OBJTYPE_MEMORY, ptr))
				break;
		}
		assert_always(tag > 0, "Failed to find alloc in pool");
	}

	return pool_realloc_file_line(pool, ptr, size, file, line);
}
コード例 #3
0
ファイル: driver-avalon2.c プロジェクト: AntoninoA/cgminer
static int64_t avalon2_scanhash(struct thr_info *thr)
{
	struct avalon2_pkg send_pkg;

	struct pool *pool;
	struct cgpu_info *avalon2 = thr->cgpu;
	struct avalon2_info *info = avalon2->device_data;

	int64_t h;
	uint32_t tmp, range, start;
	int i;

	if (thr->work_restart || thr->work_update ||
	    info->first) {
		info->new_stratum = true;
		applog(LOG_DEBUG, "Avalon2: New stratum: restart: %d, update: %d, first: %d",
		       thr->work_restart, thr->work_update, info->first);
		thr->work_update = false;
		thr->work_restart = false;
		if (unlikely(info->first))
			info->first = false;

		get_work(thr, thr->id); /* Make sure pool is ready */

		pool = current_pool();
		if (!pool->has_stratum)
			quit(1, "Avalon2: Miner Manager have to use stratum pool");
		if (pool->swork.cb_len > AVA2_P_COINBASE_SIZE)
			quit(1, "Avalon2: Miner Manager pool coinbase length have to less then %d", AVA2_P_COINBASE_SIZE);
		if (pool->swork.merkles > AVA2_P_MERKLES_COUNT)
			quit(1, "Avalon2: Miner Manager merkles have to less then %d", AVA2_P_MERKLES_COUNT);

		info->diff = (int)pool->swork.diff - 1;
		info->pool_no = pool->pool_no;

		cg_wlock(&pool->data_lock);
		avalon2_stratum_pkgs(info->fd, pool, thr);
		cg_wunlock(&pool->data_lock);

		/* Configuer the parameter from outside */
		info->fan_pwm = opt_avalon2_fan_min;
		info->set_voltage = opt_avalon2_voltage_min;
		info->set_frequency = opt_avalon2_freq_min;

		/* Set the Fan, Voltage and Frequency */
		memset(send_pkg.data, 0, AVA2_P_DATA_LEN);

		tmp = be32toh(info->fan_pwm);
		memcpy(send_pkg.data, &tmp, 4);

		tmp = encode_voltage(info->set_voltage);
		tmp = be32toh(tmp);
		memcpy(send_pkg.data + 4, &tmp, 4);

		tmp = be32toh(info->set_frequency);
		memcpy(send_pkg.data + 8, &tmp, 4);

		/* Configure the nonce2 offset and range */
		range = 0xffffffff / total_devices;
		start = range * avalon2->device_id;

		tmp = be32toh(start);
		memcpy(send_pkg.data + 12, &tmp, 4);

		tmp = be32toh(range);
		memcpy(send_pkg.data + 16, &tmp, 4);

		/* Package the data */
		avalon2_init_pkg(&send_pkg, AVA2_P_SET, 1, 1);
		while (avalon2_send_pkg(info->fd, &send_pkg, thr) != AVA2_SEND_OK)
			;
		info->new_stratum = false;
	}

	polling(thr);

	h = 0;
	for (i = 0; i < AVA2_DEFAULT_MODULARS; i++) {
		h += info->local_work[i];
	}
	return h * 0xffffffff;
}
コード例 #4
0
ファイル: restrack.c プロジェクト: broftkd/historic-mess
char *_auto_strdup(const char *str, const char *file, int line)
{
	return pool_strdup_file_line(current_pool(), str, file, line);
}
コード例 #5
0
ファイル: restrack.c プロジェクト: broftkd/historic-mess
void *_auto_realloc(void *ptr, size_t size, const char *file, int line)
{
	return pool_realloc_file_line(current_pool(), ptr, size, file, line);
}
コード例 #6
0
ファイル: restrack.c プロジェクト: broftkd/historic-mess
void *_auto_malloc(size_t size, const char *file, int line)
{
	return pool_malloc_file_line(current_pool(), size, file, line);
}
コード例 #7
0
static void spondoolies_update_work_sp50(struct cgpu_info *cgpu)
{
    struct spond_adapter *device = cgpu->device_data;
	struct thr_info *thr = cgpu->thr[0];
    struct work *work = NULL;
    struct pool *pool = NULL;

    // setup thread flags
    SPONDLOG(LOG_DEBUG, "New stratum: restart: %d, update: %d", thr->work_restart, thr->work_update);
	thr->work_update = false;
	thr->work_restart = false;

	work = get_work(thr, thr->id); /* Make sure pool is ready */
	discard_work(work); /* Don't leak memory */

    // lets check pool job parameters
    pool = current_pool();
    if (!pool->has_stratum) {
        quit(1, "%s: Miner Manager have to use stratum pool", sp50_drv.dname);
    }
    if (pool->coinbase_len > SPOND_MAX_COINBASE_LEN) {
        SPONDLOG(LOG_ERR, "Miner Manager pool coinbase length[%d] have to less then %d",
                pool->coinbase_len,
                SPOND_MAX_COINBASE_LEN);
        return;
    }
    if (pool->merkles > SPOND_MAX_MERKLES) {
        SPONDLOG(LOG_ERR, "Miner Manager merkles have to less then %d", SPOND_MAX_MERKLES);
        return;
    }
    // need to lock driver, since we may drop all jobs
    // #########   DEVICE LOCK
    //
    pthread_mutex_lock(&device->lock);
    // lock and copy pool data
    // in our case pool_no is always same number
    // but swork.job_id changes each job
    cg_rlock(&pool->data_lock);
    copy_pool_stratum(device, pool);
    cg_runlock(&pool->data_lock);
    /*
     * fill job and send it to miner
     */
    pxgate_req_packet req_packet;
    memset(&req_packet, 0, sizeof(req_packet));
    req_packet.header.protocol_version = pxgate_PROTOCOL_VERSION;
    req_packet.header.message_type = pxgate_MESSAGE_TYPE_JOB_REQ;
    req_packet.header.message_size = sizeof(req_packet)-sizeof(req_packet.header);
    // TODO: use MACRO
    req_packet.mask = 0x01; // 0x01 = first request, 0x2 = drop old work
    if (device->drop_old_jobs) {
        req_packet.mask |= 0x02; // drop old work
        device->drop_old_jobs  = 0;
    }
    // currently we will send only one job
    fill_pxgate_request(&req_packet.req, cgpu);
    // #########   DEVICE UNLOCK
    //
    pthread_mutex_unlock(&device->lock);
    do_write(device->socket_fd, &req_packet, sizeof(req_packet));
    /*
     * read the response from miner
     */
    pxgate_gen_packet rsp_packet;
    uint32_t size = 0;
    if ((size = do_read_packet(device->socket_fd, &rsp_packet, sizeof(rsp_packet))) != sizeof(rsp_packet)) {
        quit(1, "%s: critical error, packet sent from miner is bad received size[%u] expected [%u], quiting...",
                sp50_drv.dname,
                size,
                sizeof(rsp_packet)
            );
    }
    switch (rsp_packet.header.message_type) {
        case pxgate_MESSAGE_TYPE_JOB_REQ_ACK:
            SPONDLOG(LOG_DEBUG, "pxgate_MESSAGE_TYPE_JOB_REQ_ACK");
            break;
        case pxgate_MESSAGE_TYPE_JOB_REQ_REJ:
            SPONDLOG(LOG_DEBUG, "pxgate_MESSAGE_TYPE_JOB_REQ_REJ");
            break;
        default:
            SPONDLOG(LOG_ERR, "unexpected type[%x]", rsp_packet.header.message_type);
            return;
    }
    /*
     * everything is ok, we cache the job
     */
    device->current_job_id = (device->current_job_id++) % MAX_SW_JOB_INDEX_IN_MINERGATE;
}
コード例 #8
0
ファイル: driver-hashratio.c プロジェクト: 60E/cgminer
static void hashratio_update_work(struct cgpu_info *hashratio)
{
	struct hashratio_info *info = hashratio->device_data;
	struct thr_info *thr = hashratio->thr[0];
	struct hashratio_pkg send_pkg;
	uint32_t tmp, range, start;
	struct work *work;
	struct pool *pool;

	applog(LOG_DEBUG, "hashratio: New stratum: restart: %d, update: %d",
		thr->work_restart, thr->work_update);
	thr->work_update = false;
	thr->work_restart = false;

	work = get_work(thr, thr->id); /* Make sure pool is ready */
	discard_work(work); /* Don't leak memory */

	pool = current_pool();
	if (!pool->has_stratum)
		quit(1, "hashratio: Miner Manager have to use stratum pool");
	if (pool->coinbase_len > HRTO_P_COINBASE_SIZE)
		quit(1, "hashratio: Miner Manager pool coinbase length have to less then %d", HRTO_P_COINBASE_SIZE);
	if (pool->merkles > HRTO_P_MERKLES_COUNT)
		quit(1, "hashratio: Miner Manager merkles have to less then %d", HRTO_P_MERKLES_COUNT);

	info->pool_no = pool->pool_no;

	cgtime(&info->last_stratum);
	cg_rlock(&pool->data_lock);
	info->pool_no = pool->pool_no;
	copy_pool_stratum(info, pool);
	hashratio_stratum_pkgs(hashratio, pool);
	cg_runlock(&pool->data_lock);

	/* Configure the parameter from outside */
	memset(send_pkg.data, 0, HRTO_P_DATA_LEN);

	// fan. We're not measuring temperature so set a safe but not max value
	info->fan_pwm = HRTO_PWM_MAX * 2 / 3;
	tmp = be32toh(info->fan_pwm);
	memcpy(send_pkg.data, &tmp, 4);

	// freq
	tmp = be32toh(info->default_freq);
	memcpy(send_pkg.data + 4, &tmp, 4);
	applog(LOG_DEBUG, "set freq: %d", info->default_freq);

	/* Configure the nonce2 offset and range */
	range = 0xffffffff / (total_devices + 1);
	start = range * (hashratio->device_id + 1);

	tmp = be32toh(start);
	memcpy(send_pkg.data + 8, &tmp, 4);

	tmp = be32toh(range);
	memcpy(send_pkg.data + 12, &tmp, 4);

	/* Package the data */
	hashratio_init_pkg(&send_pkg, HRTO_P_SET, 1, 1);
	hashratio_send_pkgs(hashratio, &send_pkg);
}
コード例 #9
0
ファイル: restrack.c プロジェクト: broftkd/historic-mame
void *restrack_register_object(object_type type, void *ptr, size_t size, const char *file, int line)
{
	return pool_object_add_file_line(current_pool(), type, ptr, size, file, line);
}
コード例 #10
0
ファイル: driver-avalon2.c プロジェクト: february10/appDemo
static int64_t avalon2_scanhash(struct thr_info *thr)
{
	struct avalon2_pkg send_pkg;
	struct timeval current_stratum;

	struct pool *pool;
	struct cgpu_info *avalon2 = thr->cgpu;
	struct avalon2_info *info = avalon2->device_data;

	int64_t h;
	uint32_t tmp, range, start;
	int i;

	if (thr->work_restart || thr->work_update || !info->first) {
		applog(LOG_DEBUG, "Avalon2: New stratum: restart: %d, update: %d, first: %d",
		       thr->work_restart, thr->work_update, info->first);
		thr->work_update = false;
		thr->work_restart = false;
		get_work(thr, thr->id); /* Make sure pool is ready */

		pool = current_pool();
		if (!pool->has_stratum)
			quit(1, "Avalon2: Miner Manager have to use stratum pool");
		if (pool->coinbase_len > AVA2_P_COINBASE_SIZE) {
			applog(LOG_ERR, "Avalon2: Miner Manager pool coinbase length have to less then %d", AVA2_P_COINBASE_SIZE);
			return 0;
		}
		if (pool->merkles > AVA2_P_MERKLES_COUNT) {
			applog(LOG_ERR, "Avalon2: Miner Manager merkles have to less then %d", AVA2_P_MERKLES_COUNT);
			return 0;
		}

		cgtime(&info->last_stratum);
		cg_rlock(&pool->data_lock);
		info->pool_no = pool->pool_no;
		copy_pool_stratum(pool);
		avalon2_stratum_pkgs(info->fd, pool, thr);
		cg_runlock(&pool->data_lock);

		/* Configuer the parameter from outside */
		adjust_fan(info);
		info->set_voltage = opt_avalon2_voltage_min;
		info->set_frequency = opt_avalon2_freq_min;

		/* Set the Fan, Voltage and Frequency */
		memset(send_pkg.data, 0, AVA2_P_DATA_LEN);

		tmp = be32toh(info->fan_pwm);
		memcpy(send_pkg.data, &tmp, 4);

		applog(LOG_ERR, "Avalon2: Temp max: %d, Cut off temp: %d",
		       get_current_temp_max(info), opt_avalon2_overheat);
		if (get_current_temp_max(info) >= opt_avalon2_overheat)
			tmp = encode_voltage(0);
		else
			tmp = encode_voltage(info->set_voltage);
		tmp = be32toh(tmp);
		memcpy(send_pkg.data + 4, &tmp, 4);

		tmp = be32toh(info->set_frequency);
		memcpy(send_pkg.data + 8, &tmp, 4);

		/* Configure the nonce2 offset and range */
		range = 0xffffffff / total_devices;
		start = range * avalon2->device_id;

		tmp = be32toh(start);
		memcpy(send_pkg.data + 12, &tmp, 4);

		tmp = be32toh(range);
		memcpy(send_pkg.data + 16, &tmp, 4);

		/* Package the data */
		avalon2_init_pkg(&send_pkg, AVA2_P_SET, 1, 1);
		while (avalon2_send_pkg(info->fd, &send_pkg, thr) != AVA2_SEND_OK)
			;

		if (unlikely(info->first < 2))
			info->first++;
	}

	/* Stop polling the device if there is no stratum in 3 minutes, network is down */
	cgtime(&current_stratum);
	if (tdiff(&current_stratum, &(info->last_stratum)) > (double)(3.0 * 60.0))
		return 0;

	polling(thr);

	h = 0;
	for (i = 0; i < AVA2_DEFAULT_MODULARS; i++) {
		h += info->enable[i] ? (info->local_work[i] - info->hw_work[i]) : 0;
	}
	return h * 0xffffffff;
}
コード例 #11
0
ファイル: restrack.c プロジェクト: i-willh/imame4all
char *auto_strdup_file_line(running_machine *machine, const char *str, const char *file, int line)
{
    return pool_strdup_file_line(current_pool(), str, file, line);
}
コード例 #12
0
ファイル: driver-hashratio.c プロジェクト: HashRatio/cgminer
static int64_t hashratio_scanhash(struct thr_info *thr)
{
	struct hashratio_pkg send_pkg;

	struct pool *pool;
	struct cgpu_info *hashratio = thr->cgpu;
	struct hashratio_info *info = hashratio->device_data;
	struct hashratio_ret ret_pkg;
	
	uint32_t tmp, range, start;
	int i;
	
	if (thr->work_restart || thr->work_update || info->first) {
		info->new_stratum = true;
		applog(LOG_DEBUG, "hashratio: New stratum: restart: %d, update: %d, first: %d",
		       thr->work_restart, thr->work_update, info->first);
		thr->work_update = false;
		thr->work_restart = false;
		if (unlikely(info->first))
			info->first = false;

		get_work(thr, thr->id); /* Make sure pool is ready */

		pool = current_pool();
		if (!pool->has_stratum)
			quit(1, "hashratio: Miner Manager have to use stratum pool");
		if (pool->coinbase_len > HRTO_P_COINBASE_SIZE)
			quit(1, "hashratio: Miner Manager pool coinbase length have to less then %d", HRTO_P_COINBASE_SIZE);
		if (pool->merkles > HRTO_P_MERKLES_COUNT)
			quit(1, "hashratio: Miner Manager merkles have to less then %d", HRTO_P_MERKLES_COUNT);

		info->diff = (int)pool->swork.diff - 1;
		info->pool_no = pool->pool_no;

		cg_wlock(&pool->data_lock);
		hashratio_stratum_pkgs(info->fd, pool, thr);
		cg_wunlock(&pool->data_lock);
		
		/* Configuer the parameter from outside */
		memset(send_pkg.data, 0, HRTO_P_DATA_LEN);
		
		// fan
		info->fan_pwm = HRTO_PWM_MAX;
		tmp = be32toh(info->fan_pwm);
		memcpy(send_pkg.data, &tmp, 4);

		// freq
		tmp = be32toh(info->default_freq);
		memcpy(send_pkg.data + 4, &tmp, 4);
		applog(LOG_DEBUG, "set freq: %d", info->default_freq);
		
		/* Configure the nonce2 offset and range */
		range = 0xffffffff / total_devices;
		start = range * hashratio->device_id;

		tmp = be32toh(start);
		memcpy(send_pkg.data + 8, &tmp, 4);

		tmp = be32toh(range);
		memcpy(send_pkg.data + 12, &tmp, 4);

		/* Package the data */
		hashratio_init_pkg(&send_pkg, HRTO_P_SET, 1, 1);
		while (hashratio_send_pkg(info->fd, &send_pkg, thr) != HRTO_SEND_OK)
			;
		
		info->new_stratum = false;
	}

	polling(thr);
	
	return (int64_t)info->local_work * 64 * 0xffffffff;
}