libztex.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. int16_t fpgaNum;
  23. struct libusb_device_descriptor descriptor;
  24. libusb_device_handle *hndl;
  25. unsigned char usbbus;
  26. unsigned char usbaddress;
  27. unsigned char snString[LIBZTEX_SNSTRING_LEN+1];
  28. unsigned char productId[4];
  29. unsigned char fwVersion;
  30. unsigned char interfaceVersion;
  31. unsigned char interfaceCapabilities[6];
  32. unsigned char moduleReserved[12];
  33. uint8_t numNonces;
  34. uint16_t offsNonces;
  35. double freqM1;
  36. char* bitFileName;
  37. bool suspendSupported;
  38. double hashesPerClock;
  39. uint8_t extraSolutions;
  40. struct dclk_data dclk;
  41. int16_t numberOfFpgas;
  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);
  60. extern int libztex_setFreq (struct libztex_device *ztex, uint16_t freq);
  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);
  65. extern int libztex_numberOfFpgas(struct libztex_device *ztex);
  66. #endif /* __LIBZTEX_H__ */