Browse Source

Create a struct array of hashfast commands and their associated usb command names.

nfactor-troky
Con Kolivas 11 years ago
parent
commit
62f6fefb12
  1. 28
      driver-hashfast.c
  2. 1
      driver-hashfast.h
  3. 2
      usbutils.c
  4. 3
      usbutils.h

28
driver-hashfast.c

@ -13,7 +13,6 @@
#include <stdbool.h> #include <stdbool.h>
#include "usbutils.h" #include "usbutils.h"
#include "fpgautils.h"
#include "driver-hashfast.h" #include "driver-hashfast.h"
@ -96,6 +95,33 @@ static uint32_t __maybe_unused hf_crc32(unsigned char *p, int len, int plug_in)
static hf_info_t **hashfast_infos; static hf_info_t **hashfast_infos;
struct device_drv hashfast_drv; struct device_drv hashfast_drv;
struct hf_cmd {
int cmd;
char *cmd_name;
enum usb_cmds usb_cmd;
};
static const struct hf_cmd hf_cmds[] = {
{OP_NULL, "OP_NULL", C_NULL},
{OP_ROOT, "OP_ROOT", C_NULL},
{OP_RESET, "OP_RESET", C_HF_RESET},
{OP_PLL_CONFIG, "OP_PLL_CONFIG", C_HF_PLL_CONFIG},
{OP_ADDRESS, "OP_ADDRESS", C_HF_ADDRESS},
{OP_READDRESS, "OP_READDRESS", C_NULL},
{OP_HIGHEST, "OP_HIGHEST", C_NULL},
{OP_BAUD, "OP_BAUD", C_HF_BAUD},
{OP_UNROOT, "OP_UNROOT", C_NULL},
{OP_HASH, "OP_HASH", C_HF_HASH},
{OP_NONCE, "OP_NONCE", C_HF_NONCE},
{OP_ABORT, "OP_ABORT", C_HF_ABORT},
{OP_STATUS, "OP_STATUS", C_HF_STATUS},
{OP_GPIO, "OP_GPIO", C_NULL},
{OP_CONFIG, "OP_CONFIG", C_HF_CONFIG},
{OP_STATISTICS, "OP_STATISTICS", C_HF_STATISTICS},
{OP_GROUP, "OP_GROUP", C_NULL},
{OP_CLOCKGATE, "OP_CLOCKGATE", C_HF_CLOCKGATE}
};
static int hashfast_reset(struct cgpu_info __maybe_unused *hashfast) static int hashfast_reset(struct cgpu_info __maybe_unused *hashfast)
{ {
return 0; return 0;

1
driver-hashfast.h

@ -24,6 +24,7 @@
#define HF_BROADCAST_ADDRESS (uint8_t) 0xff #define HF_BROADCAST_ADDRESS (uint8_t) 0xff
// Operation codes (Second header byte) // Operation codes (Second header byte)
#define OP_NULL 0
#define OP_ROOT 1 #define OP_ROOT 1
#define OP_RESET 2 #define OP_RESET 2
#define OP_PLL_CONFIG 3 #define OP_PLL_CONFIG 3

2
usbutils.c

@ -500,6 +500,7 @@ static int next_stat = USB_NOSTAT;
static const char **usb_commands; static const char **usb_commands;
static const char *C_NULL_S = "Null";
static const char *C_REJECTED_S = "RejectedNoDevice"; static const char *C_REJECTED_S = "RejectedNoDevice";
static const char *C_PING_S = "Ping"; static const char *C_PING_S = "Ping";
static const char *C_CLEAR_S = "Clear"; static const char *C_CLEAR_S = "Clear";
@ -1001,6 +1002,7 @@ static void cgusb_check_init()
// use constants so the stat generation is very quick // use constants so the stat generation is very quick
// and the association between number and name can't // and the association between number and name can't
// be missalined easily // be missalined easily
usb_commands[C_NULL] = C_NULL_S;
usb_commands[C_REJECTED] = C_REJECTED_S; usb_commands[C_REJECTED] = C_REJECTED_S;
usb_commands[C_PING] = C_PING_S; usb_commands[C_PING] = C_PING_S;
usb_commands[C_CLEAR] = C_CLEAR_S; usb_commands[C_CLEAR] = C_CLEAR_S;

3
usbutils.h

@ -254,7 +254,8 @@ struct cg_usb_info {
}; };
enum usb_cmds { enum usb_cmds {
C_REJECTED = 0, C_NULL = 0,
C_REJECTED,
C_PING, C_PING,
C_CLEAR, C_CLEAR,
C_REQUESTVERSION, C_REQUESTVERSION,

Loading…
Cancel
Save