Skip to content

Commit

Permalink
cairnsmore: Beginnings of new driver, with automatic upgrade from Ica…
Browse files Browse the repository at this point in the history
…rus detection

CAIRNSMORE1_HASH_TIME based on 10000 samples
  • Loading branch information
luke-jr committed Sep 14, 2012
1 parent bbb834a commit 8445ce8
Show file tree
Hide file tree
Showing 8 changed files with 281 additions and 117 deletions.
3 changes: 2 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ endif
endif

if HAS_ICARUS
bfgminer_SOURCES += driver-icarus.c
bfgminer_SOURCES += driver-icarus.c icarus-common.h
bfgminer_SOURCES += driver-cairnsmore.c
endif

if HAS_MODMINER
Expand Down
70 changes: 70 additions & 0 deletions driver-cairnsmore.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* Copyright 2012 Luke Dashjr
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option)
* any later version. See COPYING for more details.
*/

#include "fpgautils.h"
#include "icarus-common.h"
#include "miner.h"

#define CAIRNSMORE1_IO_SPEED 115200
#define CAIRNSMORE1_HASH_TIME 0.0000000024484

struct device_api cairnsmore_api;

static bool cairnsmore_detect_one(const char *devpath)
{
struct ICARUS_INFO *info = calloc(1, sizeof(struct ICARUS_INFO));
if (unlikely(!info))
quit(1, "Failed to malloc ICARUS_INFO");

info->baud = CAIRNSMORE1_IO_SPEED;
info->work_division = 2;
info->fpga_count = 2;
info->quirk_reopen = false;

if (!icarus_detect_custom(devpath, &cairnsmore_api, info)) {
free(info);
return false;
}
return true;
}

static int cairnsmore_detect_auto(void)
{
return
serial_autodetect_udev (cairnsmore_detect_one, "*Cairnsmore1*") ?:
serial_autodetect_devserial(cairnsmore_detect_one, "Cairnsmore1") ?:
0;
}

static void cairnsmore_detect()
{
// Actual serial detection is handled by Icarus driver
serial_detect_auto_byname(cairnsmore_api.dname, cairnsmore_detect_one, cairnsmore_detect_auto);
}

void convert_icarus_to_cairnsmore(struct cgpu_info *cm1)
{
struct ICARUS_INFO *info = cm1->cgpu_data;
info->Hs = CAIRNSMORE1_HASH_TIME;
info->fullnonce = info->Hs * (((double)0xffffffff) + 1);
info->read_count = (int)(info->fullnonce * TIME_FACTOR) - 1;
cm1->api = &cairnsmore_api;
renumber_cgpu(cm1);
}

extern struct device_api icarus_api;

__attribute__((constructor(1000)))
static void cairnsmore_api_init()
{
cairnsmore_api = icarus_api;
cairnsmore_api.dname = "cairnsmore";
cairnsmore_api.name = "ECM";
cairnsmore_api.api_detect = cairnsmore_detect;
}
Loading

0 comments on commit 8445ce8

Please sign in to comment.