libztex.h 2.2 KB

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