Browse Source

Merge branch 'master' into hashfast

Conflicts:
	usbutils.c
	usbutils.h
nfactor-troky
Con Kolivas 11 years ago
parent
commit
293622cf2a
  1. 1
      driver-hashfast.c
  2. 168
      usbutils.c
  3. 155
      usbutils.h

1
driver-hashfast.c

@ -101,6 +101,7 @@ struct hf_cmd {
enum usb_cmds usb_cmd; enum usb_cmds usb_cmd;
}; };
#define C_NULL C_MAX
static const struct hf_cmd hf_cmds[] = { static const struct hf_cmd hf_cmds[] = {
{OP_NULL, "OP_NULL", C_NULL}, {OP_NULL, "OP_NULL", C_NULL},
{OP_ROOT, "OP_ROOT", C_NULL}, {OP_ROOT, "OP_ROOT", C_NULL},

168
usbutils.c

@ -542,83 +542,13 @@ static int next_stat = USB_NOSTAT;
#endif // DO_USB_STATS #endif // DO_USB_STATS
static const char **usb_commands; /* Create usb_commands array from USB_PARSE_COMMANDS macro in usbutils.h */
#define USB_ADD_COMMAND(X, Y) Y,
static const char *C_NULL_S = "Null"; char *usb_commands[] = {
static const char *C_REJECTED_S = "RejectedNoDevice"; USB_PARSE_COMMANDS
static const char *C_PING_S = "Ping"; "Null"
static const char *C_CLEAR_S = "Clear"; };
static const char *C_REQUESTVERSION_S = "RequestVersion"; #undef USB_ADD_COMMAND
static const char *C_GETVERSION_S = "GetVersion";
static const char *C_REQUESTFPGACOUNT_S = "RequestFPGACount";
static const char *C_GETFPGACOUNT_S = "GetFPGACount";
static const char *C_STARTPROGRAM_S = "StartProgram";
static const char *C_STARTPROGRAMSTATUS_S = "StartProgramStatus";
static const char *C_PROGRAM_S = "Program";
static const char *C_PROGRAMSTATUS_S = "ProgramStatus";
static const char *C_PROGRAMSTATUS2_S = "ProgramStatus2";
static const char *C_FINALPROGRAMSTATUS_S = "FinalProgramStatus";
static const char *C_SETCLOCK_S = "SetClock";
static const char *C_REPLYSETCLOCK_S = "ReplySetClock";
static const char *C_REQUESTUSERCODE_S = "RequestUserCode";
static const char *C_GETUSERCODE_S = "GetUserCode";
static const char *C_REQUESTTEMPERATURE_S = "RequestTemperature";
static const char *C_GETTEMPERATURE_S = "GetTemperature";
static const char *C_SENDWORK_S = "SendWork";
static const char *C_SENDWORKSTATUS_S = "SendWorkStatus";
static const char *C_REQUESTWORKSTATUS_S = "RequestWorkStatus";
static const char *C_GETWORKSTATUS_S = "GetWorkStatus";
static const char *C_REQUESTIDENTIFY_S = "RequestIdentify";
static const char *C_GETIDENTIFY_S = "GetIdentify";
static const char *C_REQUESTFLASH_S = "RequestFlash";
static const char *C_REQUESTSENDWORK_S = "RequestSendWork";
static const char *C_REQUESTSENDWORKSTATUS_S = "RequestSendWorkStatus";
static const char *C_RESET_S = "Reset";
static const char *C_SETBAUD_S = "SetBaud";
static const char *C_SETDATA_S = "SetDataCtrl";
static const char *C_SETFLOW_S = "SetFlowCtrl";
static const char *C_SETMODEM_S = "SetModemCtrl";
static const char *C_PURGERX_S = "PurgeRx";
static const char *C_PURGETX_S = "PurgeTx";
static const char *C_FLASHREPLY_S = "FlashReply";
static const char *C_REQUESTDETAILS_S = "RequestDetails";
static const char *C_GETDETAILS_S = "GetDetails";
static const char *C_REQUESTRESULTS_S = "RequestResults";
static const char *C_GETRESULTS_S = "GetResults";
static const char *C_REQUESTQUEJOB_S = "RequestQueJob";
static const char *C_REQUESTQUEJOBSTATUS_S = "RequestQueJobStatus";
static const char *C_QUEJOB_S = "QueJob";
static const char *C_QUEJOBSTATUS_S = "QueJobStatus";
static const char *C_QUEFLUSH_S = "QueFlush";
static const char *C_QUEFLUSHREPLY_S = "QueFlushReply";
static const char *C_REQUESTVOLTS_S = "RequestVolts";
static const char *C_GETVOLTS_S = "GetVolts";
static const char *C_SENDTESTWORK_S = "SendTestWork";
static const char *C_LATENCY_S = "SetLatency";
static const char *C_SETLINE_S = "SetLine";
static const char *C_VENDOR_S = "Vendor";
static const char *C_SETFAN_S = "SetFan";
static const char *C_FANREPLY_S = "GetFan";
static const char *C_AVALON_TASK_S = "AvalonTask";
static const char *C_AVALON_READ_S = "AvalonRead";
static const char *C_GET_AVALON_READY_S = "AvalonReady";
static const char *C_AVALON_RESET_S = "AvalonReset";
static const char *C_GET_AVALON_RESET_S = "GetAvalonReset";
static const char *C_FTDI_STATUS_S = "FTDIStatus";
static const char *C_ENABLE_UART_S = "EnableUART";
static const char *C_BB_SET_VOLTAGE_S = "SetCoreVoltage";
static const char *C_BB_GET_VOLTAGE_S = "GetCoreVoltage";
static const char *C_HF_RESET_S = "HFReset";
static const char *C_HF_PLL_CONFIG_S = "HFPLLConfig";
static const char *C_HF_ADDRESS_S = "HFAddress";
static const char *C_HF_BAUD_S = "HFBaud";
static const char *C_HF_HASH_S = "HFHash";
static const char *C_HF_NONCE_S = "HFNonce";
static const char *C_HF_ABORT_S = "HFAbort";
static const char *C_HF_STATUS_S = "HFStatus";
static const char *C_HF_CONFIG_S = "HFConfig";
static const char *C_HF_STATISTICS_S = "HFStatistics";
static const char *C_HF_CLOCKGATE_S = "HFClockGate";
#ifdef EOL #ifdef EOL
#undef EOL #undef EOL
@ -1038,90 +968,6 @@ static void cgusb_check_init()
libusb_set_debug(NULL, opt_usbdump); libusb_set_debug(NULL, opt_usbdump);
usb_all(opt_usbdump); usb_all(opt_usbdump);
} }
usb_commands = malloc(sizeof(*usb_commands) * C_MAX);
if (unlikely(!usb_commands))
quit(1, "USB failed to malloc usb_commands");
// use constants so the stat generation is very quick
// and the association between number and name can't
// be missalined easily
usb_commands[C_NULL] = C_NULL_S;
usb_commands[C_REJECTED] = C_REJECTED_S;
usb_commands[C_PING] = C_PING_S;
usb_commands[C_CLEAR] = C_CLEAR_S;
usb_commands[C_REQUESTVERSION] = C_REQUESTVERSION_S;
usb_commands[C_GETVERSION] = C_GETVERSION_S;
usb_commands[C_REQUESTFPGACOUNT] = C_REQUESTFPGACOUNT_S;
usb_commands[C_GETFPGACOUNT] = C_GETFPGACOUNT_S;
usb_commands[C_STARTPROGRAM] = C_STARTPROGRAM_S;
usb_commands[C_STARTPROGRAMSTATUS] = C_STARTPROGRAMSTATUS_S;
usb_commands[C_PROGRAM] = C_PROGRAM_S;
usb_commands[C_PROGRAMSTATUS] = C_PROGRAMSTATUS_S;
usb_commands[C_PROGRAMSTATUS2] = C_PROGRAMSTATUS2_S;
usb_commands[C_FINALPROGRAMSTATUS] = C_FINALPROGRAMSTATUS_S;
usb_commands[C_SETCLOCK] = C_SETCLOCK_S;
usb_commands[C_REPLYSETCLOCK] = C_REPLYSETCLOCK_S;
usb_commands[C_REQUESTUSERCODE] = C_REQUESTUSERCODE_S;
usb_commands[C_GETUSERCODE] = C_GETUSERCODE_S;
usb_commands[C_REQUESTTEMPERATURE] = C_REQUESTTEMPERATURE_S;
usb_commands[C_GETTEMPERATURE] = C_GETTEMPERATURE_S;
usb_commands[C_SENDWORK] = C_SENDWORK_S;
usb_commands[C_SENDWORKSTATUS] = C_SENDWORKSTATUS_S;
usb_commands[C_REQUESTWORKSTATUS] = C_REQUESTWORKSTATUS_S;
usb_commands[C_GETWORKSTATUS] = C_GETWORKSTATUS_S;
usb_commands[C_REQUESTIDENTIFY] = C_REQUESTIDENTIFY_S;
usb_commands[C_GETIDENTIFY] = C_GETIDENTIFY_S;
usb_commands[C_REQUESTFLASH] = C_REQUESTFLASH_S;
usb_commands[C_REQUESTSENDWORK] = C_REQUESTSENDWORK_S;
usb_commands[C_REQUESTSENDWORKSTATUS] = C_REQUESTSENDWORKSTATUS_S;
usb_commands[C_RESET] = C_RESET_S;
usb_commands[C_SETBAUD] = C_SETBAUD_S;
usb_commands[C_SETDATA] = C_SETDATA_S;
usb_commands[C_SETFLOW] = C_SETFLOW_S;
usb_commands[C_SETMODEM] = C_SETMODEM_S;
usb_commands[C_PURGERX] = C_PURGERX_S;
usb_commands[C_PURGETX] = C_PURGETX_S;
usb_commands[C_FLASHREPLY] = C_FLASHREPLY_S;
usb_commands[C_REQUESTDETAILS] = C_REQUESTDETAILS_S;
usb_commands[C_GETDETAILS] = C_GETDETAILS_S;
usb_commands[C_REQUESTRESULTS] = C_REQUESTRESULTS_S;
usb_commands[C_GETRESULTS] = C_GETRESULTS_S;
usb_commands[C_REQUESTQUEJOB] = C_REQUESTQUEJOB_S;
usb_commands[C_REQUESTQUEJOBSTATUS] = C_REQUESTQUEJOBSTATUS_S;
usb_commands[C_QUEJOB] = C_QUEJOB_S;
usb_commands[C_QUEJOBSTATUS] = C_QUEJOBSTATUS_S;
usb_commands[C_QUEFLUSH] = C_QUEFLUSH_S;
usb_commands[C_QUEFLUSHREPLY] = C_QUEFLUSHREPLY_S;
usb_commands[C_REQUESTVOLTS] = C_REQUESTVOLTS_S;
usb_commands[C_GETVOLTS] = C_GETVOLTS_S;
usb_commands[C_SENDTESTWORK] = C_SENDTESTWORK_S;
usb_commands[C_LATENCY] = C_LATENCY_S;
usb_commands[C_SETLINE] = C_SETLINE_S;
usb_commands[C_VENDOR] = C_VENDOR_S;
usb_commands[C_SETFAN] = C_SETFAN_S;
usb_commands[C_FANREPLY] = C_FANREPLY_S;
usb_commands[C_AVALON_TASK] = C_AVALON_TASK_S;
usb_commands[C_AVALON_READ] = C_AVALON_READ_S;
usb_commands[C_GET_AVALON_READY] = C_GET_AVALON_READY_S;
usb_commands[C_AVALON_RESET] = C_AVALON_RESET_S;
usb_commands[C_GET_AVALON_RESET] = C_GET_AVALON_RESET_S;
usb_commands[C_FTDI_STATUS] = C_FTDI_STATUS_S;
usb_commands[C_ENABLE_UART] = C_ENABLE_UART_S;
usb_commands[C_BB_SET_VOLTAGE] = C_BB_SET_VOLTAGE_S;
usb_commands[C_BB_GET_VOLTAGE] = C_BB_GET_VOLTAGE_S;
usb_commands[C_HF_RESET] = C_HF_RESET_S;
usb_commands[C_HF_PLL_CONFIG] = C_HF_PLL_CONFIG_S;
usb_commands[C_HF_ADDRESS] = C_HF_ADDRESS_S;
usb_commands[C_HF_BAUD] = C_HF_BAUD_S;
usb_commands[C_HF_HASH] = C_HF_HASH_S;
usb_commands[C_HF_NONCE] = C_HF_NONCE_S;
usb_commands[C_HF_ABORT] = C_HF_ABORT_S;
usb_commands[C_HF_STATUS] = C_HF_STATUS_S;
usb_commands[C_HF_CONFIG] = C_HF_CONFIG_S;
usb_commands[C_HF_STATISTICS] = C_HF_STATISTICS_S;
usb_commands[C_HF_CLOCKGATE] = C_HF_CLOCKGATE_S;
stats_initialised = true; stats_initialised = true;
} }

155
usbutils.h

@ -258,84 +258,89 @@ struct cg_usb_info {
struct cg_usb_tmo usb_tmo[USB_TMOS]; struct cg_usb_tmo usb_tmo[USB_TMOS];
}; };
#define USB_PARSE_COMMANDS \
USB_ADD_COMMAND(C_REJECTED, "RejectedNoDevice") \
USB_ADD_COMMAND(C_PING, "Ping") \
USB_ADD_COMMAND(C_CLEAR, "Clear") \
USB_ADD_COMMAND(C_REQUESTVERSION, "RequestVersion") \
USB_ADD_COMMAND(C_GETVERSION, "GetVersion") \
USB_ADD_COMMAND(C_REQUESTFPGACOUNT, "RequestFPGACount") \
USB_ADD_COMMAND(C_GETFPGACOUNT, "GetFPGACount") \
USB_ADD_COMMAND(C_STARTPROGRAM, "StartProgram") \
USB_ADD_COMMAND(C_STARTPROGRAMSTATUS, "StartProgramStatus") \
USB_ADD_COMMAND(C_PROGRAM, "Program") \
USB_ADD_COMMAND(C_PROGRAMSTATUS, "ProgramStatus") \
USB_ADD_COMMAND(C_PROGRAMSTATUS2, "ProgramStatus2") \
USB_ADD_COMMAND(C_FINALPROGRAMSTATUS, "FinalProgramStatus") \
USB_ADD_COMMAND(C_SETCLOCK, "SetClock") \
USB_ADD_COMMAND(C_REPLYSETCLOCK, "ReplySetClock") \
USB_ADD_COMMAND(C_REQUESTUSERCODE, "RequestUserCode") \
USB_ADD_COMMAND(C_GETUSERCODE, "GetUserCode") \
USB_ADD_COMMAND(C_REQUESTTEMPERATURE, "RequestTemperature") \
USB_ADD_COMMAND(C_GETTEMPERATURE, "GetTemperature") \
USB_ADD_COMMAND(C_SENDWORK, "SendWork") \
USB_ADD_COMMAND(C_SENDWORKSTATUS, "SendWorkStatus") \
USB_ADD_COMMAND(C_REQUESTWORKSTATUS, "RequestWorkStatus") \
USB_ADD_COMMAND(C_GETWORKSTATUS, "GetWorkStatus") \
USB_ADD_COMMAND(C_REQUESTIDENTIFY, "RequestIdentify") \
USB_ADD_COMMAND(C_GETIDENTIFY, "GetIdentify") \
USB_ADD_COMMAND(C_REQUESTFLASH, "RequestFlash") \
USB_ADD_COMMAND(C_REQUESTSENDWORK, "RequestSendWork") \
USB_ADD_COMMAND(C_REQUESTSENDWORKSTATUS, "RequestSendWorkStatus") \
USB_ADD_COMMAND(C_RESET, "Reset") \
USB_ADD_COMMAND(C_SETBAUD, "SetBaud") \
USB_ADD_COMMAND(C_SETDATA, "SetDataCtrl") \
USB_ADD_COMMAND(C_SETFLOW, "SetFlowCtrl") \
USB_ADD_COMMAND(C_SETMODEM, "SetModemCtrl") \
USB_ADD_COMMAND(C_PURGERX, "PurgeRx") \
USB_ADD_COMMAND(C_PURGETX, "PurgeTx") \
USB_ADD_COMMAND(C_FLASHREPLY, "FlashReply") \
USB_ADD_COMMAND(C_REQUESTDETAILS, "RequestDetails") \
USB_ADD_COMMAND(C_GETDETAILS, "GetDetails") \
USB_ADD_COMMAND(C_REQUESTRESULTS, "RequestResults") \
USB_ADD_COMMAND(C_GETRESULTS, "GetResults") \
USB_ADD_COMMAND(C_REQUESTQUEJOB, "RequestQueJob") \
USB_ADD_COMMAND(C_REQUESTQUEJOBSTATUS, "RequestQueJobStatus") \
USB_ADD_COMMAND(C_QUEJOB, "QueJob") \
USB_ADD_COMMAND(C_QUEJOBSTATUS, "QueJobStatus") \
USB_ADD_COMMAND(C_QUEFLUSH, "QueFlush") \
USB_ADD_COMMAND(C_QUEFLUSHREPLY, "QueFlushReply") \
USB_ADD_COMMAND(C_REQUESTVOLTS, "RequestVolts") \
USB_ADD_COMMAND(C_GETVOLTS, "GetVolts") \
USB_ADD_COMMAND(C_SENDTESTWORK, "SendTestWork") \
USB_ADD_COMMAND(C_LATENCY, "SetLatency") \
USB_ADD_COMMAND(C_SETLINE, "SetLine") \
USB_ADD_COMMAND(C_VENDOR, "Vendor") \
USB_ADD_COMMAND(C_SETFAN, "SetFan") \
USB_ADD_COMMAND(C_FANREPLY, "GetFan") \
USB_ADD_COMMAND(C_AVALON_TASK, "AvalonTask") \
USB_ADD_COMMAND(C_AVALON_READ, "AvalonRead") \
USB_ADD_COMMAND(C_GET_AVALON_READY, "AvalonReady") \
USB_ADD_COMMAND(C_AVALON_RESET, "AvalonReset") \
USB_ADD_COMMAND(C_GET_AVALON_RESET, "GetAvalonReset") \
USB_ADD_COMMAND(C_FTDI_STATUS, "FTDIStatus") \
USB_ADD_COMMAND(C_ENABLE_UART, "EnableUART") \
USB_ADD_COMMAND(C_BB_SET_VOLTAGE, "SetCoreVoltage") \
USB_ADD_COMMAND(C_BB_GET_VOLTAGE, "GetCoreVoltage") \
USB_ADD_COMMAND(C_HF_RESET, "HFReset") \
USB_ADD_COMMAND(C_HF_PLL_CONFIG, "HFPLLConfig") \
USB_ADD_COMMAND(C_HF_ADDRESS, "HFAddress") \
USB_ADD_COMMAND(C_HF_BAUD, "HFBaud") \
USB_ADD_COMMAND(C_HF_HASH, "HFHash") \
USB_ADD_COMMAND(C_HF_NONCE, "HFNonce") \
USB_ADD_COMMAND(C_HF_ABORT, "HFAbort") \
USB_ADD_COMMAND(C_HF_STATUS, "HFStatus") \
USB_ADD_COMMAND(C_HF_CONFIG, "HFConfig") \
USB_ADD_COMMAND(C_HF_STATISTICS, "HFStatistics") \
USB_ADD_COMMAND(C_HF_CLOCKGATE, "HFClockGate")
/* Create usb_cmds enum from USB_PARSE_COMMANDS macro */
#define USB_ADD_COMMAND(X, Y) X,
enum usb_cmds { enum usb_cmds {
C_NULL = 0, USB_PARSE_COMMANDS
C_REJECTED,
C_PING,
C_CLEAR,
C_REQUESTVERSION,
C_GETVERSION,
C_REQUESTFPGACOUNT,
C_GETFPGACOUNT,
C_STARTPROGRAM,
C_STARTPROGRAMSTATUS,
C_PROGRAM,
C_PROGRAMSTATUS,
C_PROGRAMSTATUS2,
C_FINALPROGRAMSTATUS,
C_SETCLOCK,
C_REPLYSETCLOCK,
C_REQUESTUSERCODE,
C_GETUSERCODE,
C_REQUESTTEMPERATURE,
C_GETTEMPERATURE,
C_SENDWORK,
C_SENDWORKSTATUS,
C_REQUESTWORKSTATUS,
C_GETWORKSTATUS,
C_REQUESTIDENTIFY,
C_GETIDENTIFY,
C_REQUESTFLASH,
C_REQUESTSENDWORK,
C_REQUESTSENDWORKSTATUS,
C_RESET,
C_SETBAUD,
C_SETDATA,
C_SETFLOW,
C_SETMODEM,
C_PURGERX,
C_PURGETX,
C_FLASHREPLY,
C_REQUESTDETAILS,
C_GETDETAILS,
C_REQUESTRESULTS,
C_GETRESULTS,
C_REQUESTQUEJOB,
C_REQUESTQUEJOBSTATUS,
C_QUEJOB,
C_QUEJOBSTATUS,
C_QUEFLUSH,
C_QUEFLUSHREPLY,
C_REQUESTVOLTS,
C_GETVOLTS,
C_SENDTESTWORK,
C_LATENCY,
C_SETLINE,
C_VENDOR,
C_SETFAN,
C_FANREPLY,
C_AVALON_TASK,
C_AVALON_READ,
C_GET_AVALON_READY,
C_AVALON_RESET,
C_GET_AVALON_RESET,
C_FTDI_STATUS,
C_ENABLE_UART,
C_BB_SET_VOLTAGE,
C_BB_GET_VOLTAGE,
C_HF_RESET,
C_HF_PLL_CONFIG,
C_HF_ADDRESS,
C_HF_BAUD,
C_HF_HASH,
C_HF_NONCE,
C_HF_ABORT,
C_HF_STATUS,
C_HF_CONFIG,
C_HF_STATISTICS,
C_HF_CLOCKGATE,
C_MAX C_MAX
}; };
#undef USB_ADD_COMMAND
struct device_drv; struct device_drv;
struct cgpu_info; struct cgpu_info;

Loading…
Cancel
Save