libztex.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #ifndef __LIBZTEX_H__
  2. #define __LIBZTEX_H__
  3. #include <libusb.h>
  4. #include "dynclock.h"
  5. #define LIBZTEX_MAX_DESCRIPTORS 512
  6. #define LIBZTEX_SNSTRING_LEN 10
  7. #define LIBZTEX_IDVENDOR 0x221A
  8. #define LIBZTEX_IDPRODUCT 0x0100
  9. struct libztex_fpgastate {
  10. bool fpgaConfigured;
  11. unsigned char fpgaChecksum;
  12. uint16_t fpgaBytes;
  13. unsigned char fpgaInitB;
  14. unsigned char fpgaFlashResult;
  15. bool fpgaFlashBitSwap;
  16. };
  17. struct libztex_device {
  18. pthread_mutex_t mutex;
  19. struct libztex_device *root;
  20. struct libusb_device_descriptor descriptor;
  21. libusb_device_handle *hndl;
  22. unsigned char usbbus;
  23. unsigned char usbaddress;
  24. unsigned char snString[LIBZTEX_SNSTRING_LEN+1];
  25. unsigned char productId[4];
  26. unsigned char fwVersion;
  27. unsigned char interfaceVersion;
  28. unsigned char interfaceCapabilities[6];
  29. unsigned char moduleReserved[12];
  30. uint8_t numNonces;
  31. uint16_t offsNonces;
  32. double freqM1;
  33. char* bitFileName;
  34. bool suspendSupported;
  35. double hashesPerClock;
  36. uint8_t extraSolutions;
  37. struct dclk_data dclk;
  38. int16_t numberOfFpgas;
  39. int handles;
  40. int selectedFpga;
  41. bool parallelConfigSupport;
  42. char repr[20];
  43. };
  44. struct libztex_dev_list {
  45. struct libztex_device *dev;
  46. struct libztex_dev_list *next;
  47. };
  48. struct libztex_hash_data {
  49. uint32_t goldenNonce[2];
  50. uint32_t nonce;
  51. uint32_t hash7;
  52. };
  53. extern int libztex_scanDevices (struct libztex_dev_list ***devs);
  54. extern void libztex_freeDevList (struct libztex_dev_list **devs);
  55. extern int libztex_prepare_device (struct libusb_device *dev, struct libztex_device** ztex);
  56. extern void libztex_destroy_device (struct libztex_device* ztex);
  57. extern int libztex_configureFpga (struct libztex_device *dev, const char *repr);
  58. extern int libztex_setFreq (struct libztex_device *ztex, uint16_t freq, const char *repr);
  59. extern int libztex_sendHashData (struct libztex_device *ztex, unsigned char *sendbuf);
  60. extern int libztex_readHashData (struct libztex_device *ztex, struct libztex_hash_data nonces[]);
  61. extern int libztex_resetFpga (struct libztex_device *ztex);
  62. extern int libztex_selectFpga(struct libztex_device *ztex, int16_t fpgaNum);
  63. extern int libztex_numberOfFpgas(struct libztex_device *ztex);
  64. #endif /* __LIBZTEX_H__ */