driver-spondoolies-sp30-p.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * Copyright 2014 Zvi (Zvisha) Shteingart - Spondoolies-tech.com
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of the GNU General Public License as published by the Free
  6. * Software Foundation; either version 3 of the License, or (at your option)
  7. * any later version. See COPYING for more details.
  8. *
  9. * Note that changing this SW will void your miners guaranty
  10. */
  11. #ifndef ____MINERGATE_LIB30_H___
  12. #define ____MINERGATE_LIB30_H___
  13. #include <stdio.h>
  14. #include <stdlib.h>
  15. #include <getopt.h>
  16. #include <fcntl.h>
  17. #include <sys/ioctl.h>
  18. #include <linux/types.h>
  19. #include <linux/spi/spidev.h>
  20. #include <netinet/in.h>
  21. #define MINERGATE_PROTOCOL_VERSION_SP30 30
  22. #define MINERGATE_SOCKET_FILE_SP30 "/tmp/connection_pipe_sp30"
  23. typedef enum {
  24. MINERGATE_DATA_ID_DO_JOB_REQ_SP30 = 5,
  25. MINERGATE_DATA_ID_DO_JOB_RSP_SP30 = 6,
  26. } MINERGATE_DATA_ID_SP30;
  27. typedef struct {
  28. uint32_t work_id_in_sw;
  29. uint32_t difficulty;
  30. uint32_t timestamp;
  31. uint32_t mrkle_root;
  32. uint32_t midstate[8];
  33. uint8_t leading_zeroes;
  34. uint8_t ntime_limit; // max ntime - should be 60
  35. uint8_t resr2;
  36. uint8_t resr1;
  37. } minergate_do_job_req_sp30;
  38. #define MAX_REQUESTS_SP30 30
  39. #define MAX_RESPONDS_SP30 60
  40. #define MINERGATE_ADAPTER_QUEUE_SP30 40
  41. typedef struct {
  42. uint32_t work_id_in_sw;
  43. uint32_t mrkle_root; // to validate
  44. uint32_t winner_nonce;
  45. uint8_t ntime_offset;
  46. uint8_t res; // 0 = done, 1 = overflow, 2 = dropped bist
  47. uint8_t job_complete;
  48. uint8_t resrv2;
  49. } minergate_do_job_rsp_sp30;
  50. typedef struct {
  51. uint8_t requester_id;
  52. uint8_t request_id;
  53. uint8_t protocol_version;
  54. uint8_t mask; // 0x01 = first request, 0x2 = drop old work
  55. uint16_t magic; // 0xcaf4
  56. uint16_t req_count;
  57. minergate_do_job_req_sp30 req[MAX_REQUESTS_SP30]; // array of requests
  58. } minergate_req_packet_sp30;
  59. typedef struct {
  60. uint8_t requester_id;
  61. uint8_t request_id;
  62. uint8_t protocol_version;
  63. uint8_t gh_div_50_rate;
  64. uint16_t magic; // 0xcaf4
  65. uint16_t rsp_count;
  66. minergate_do_job_rsp_sp30 rsp[MAX_RESPONDS_SP30]; // array of responces
  67. } minergate_rsp_packet_sp30;
  68. minergate_req_packet_sp30* allocate_minergate_packet_req_sp30(uint8_t requester_id,uint8_t request_id);
  69. minergate_rsp_packet_sp30* allocate_minergate_packet_rsp_sp30(uint8_t requester_id,uint8_t request_id);
  70. #endif