libztex.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. char *dev_manufacturer;
  25. char *dev_product;
  26. unsigned char snString[LIBZTEX_SNSTRING_LEN+1];
  27. unsigned char productId[4];
  28. unsigned char fwVersion;
  29. unsigned char interfaceVersion;
  30. unsigned char interfaceCapabilities[6];
  31. unsigned char moduleReserved[12];
  32. uint8_t numNonces;
  33. uint16_t offsNonces;
  34. double freqM1;
  35. char* bitFileName;
  36. bool suspendSupported;
  37. double hashesPerClock;
  38. uint8_t extraSolutions;
  39. struct dclk_data dclk;
  40. int16_t numberOfFpgas;
  41. int handles;
  42. int selectedFpga;
  43. bool parallelConfigSupport;
  44. char repr[20];
  45. };
  46. struct libztex_dev_list {
  47. struct libztex_device *dev;
  48. struct libztex_dev_list *next;
  49. };
  50. struct libztex_hash_data {
  51. uint32_t goldenNonce[2];
  52. uint32_t nonce;
  53. uint32_t hash7;
  54. };
  55. extern int libztex_scanDevices (struct libztex_dev_list ***devs);
  56. extern void libztex_freeDevList (struct libztex_dev_list **devs);
  57. extern int libztex_prepare_device (struct libusb_device *dev, struct libztex_device** ztex);
  58. extern void libztex_destroy_device (struct libztex_device* ztex);
  59. extern int libztex_configureFpga (struct libztex_device *dev, const char *repr);
  60. extern int libztex_setFreq (struct libztex_device *ztex, uint16_t freq, const char *repr);
  61. extern int libztex_sendHashData (struct libztex_device *ztex, unsigned char *sendbuf);
  62. extern int libztex_readHashData (struct libztex_device *ztex, struct libztex_hash_data nonces[]);
  63. extern int libztex_resetFpga (struct libztex_device *ztex);
  64. extern int libztex_selectFpga(struct libztex_device *ztex, int16_t fpgaNum);
  65. extern int libztex_numberOfFpgas(struct libztex_device *ztex);
  66. #endif /* __LIBZTEX_H__ */