libztex.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /**
  2. * libztex.h - headers for Ztex 1.15x fpga board support library
  3. *
  4. * Copyright 2012 nelisky.btc@gmail.com
  5. * Copyright 2012 Luke Dashjr
  6. *
  7. * This work is based upon the Java SDK provided by ztex which is
  8. * Copyright (C) 2009-2011 ZTEX GmbH.
  9. * http://www.ztex.de
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License version 2 as
  13. * published by the Free Software Foundation.
  14. *
  15. * This program is distributed in the hope that it will be useful, but
  16. * WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, see http://www.gnu.org/licenses/.
  22. **/
  23. #ifndef __LIBZTEX_H__
  24. #define __LIBZTEX_H__
  25. #include <libusb.h>
  26. #include "dynclock.h"
  27. #define LIBZTEX_MAX_DESCRIPTORS 512
  28. #define LIBZTEX_SNSTRING_LEN 10
  29. #define LIBZTEX_IDVENDOR 0x221A
  30. #define LIBZTEX_IDPRODUCT 0x0100
  31. struct libztex_fpgastate {
  32. bool fpgaConfigured;
  33. unsigned char fpgaChecksum;
  34. uint16_t fpgaBytes;
  35. unsigned char fpgaInitB;
  36. unsigned char fpgaFlashResult;
  37. bool fpgaFlashBitSwap;
  38. };
  39. struct libztex_device {
  40. pthread_mutex_t mutex;
  41. struct libztex_device *root;
  42. int16_t fpgaNum;
  43. struct libusb_device_descriptor descriptor;
  44. libusb_device_handle *hndl;
  45. unsigned char usbbus;
  46. unsigned char usbaddress;
  47. unsigned char snString[LIBZTEX_SNSTRING_LEN+1];
  48. unsigned char productId[4];
  49. unsigned char fwVersion;
  50. unsigned char interfaceVersion;
  51. unsigned char interfaceCapabilities[6];
  52. unsigned char moduleReserved[12];
  53. uint8_t numNonces;
  54. uint16_t offsNonces;
  55. double freqM1;
  56. char* bitFileName;
  57. bool suspendSupported;
  58. double hashesPerClock;
  59. uint8_t extraSolutions;
  60. struct dclk_data dclk;
  61. int16_t numberOfFpgas;
  62. int selectedFpga;
  63. bool parallelConfigSupport;
  64. char repr[20];
  65. };
  66. struct libztex_dev_list {
  67. struct libztex_device *dev;
  68. struct libztex_dev_list *next;
  69. };
  70. struct libztex_hash_data {
  71. uint32_t goldenNonce[2];
  72. uint32_t nonce;
  73. uint32_t hash7;
  74. };
  75. extern int libztex_scanDevices (struct libztex_dev_list ***devs);
  76. extern void libztex_freeDevList (struct libztex_dev_list **devs);
  77. extern int libztex_prepare_device (struct libusb_device *dev, struct libztex_device** ztex);
  78. extern void libztex_destroy_device (struct libztex_device* ztex);
  79. extern int libztex_configureFpga (struct libztex_device *dev);
  80. extern int libztex_setFreq (struct libztex_device *ztex, uint16_t freq);
  81. extern int libztex_sendHashData (struct libztex_device *ztex, unsigned char *sendbuf);
  82. extern int libztex_readHashData (struct libztex_device *ztex, struct libztex_hash_data nonces[]);
  83. extern int libztex_resetFpga (struct libztex_device *ztex);
  84. extern int libztex_selectFpga(struct libztex_device *ztex);
  85. extern int libztex_numberOfFpgas(struct libztex_device *ztex);
  86. #endif /* __LIBZTEX_H__ */