driver-spondoolies-sp30-p.h 2.4 KB

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