driver-spondoolies-sp10-p.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * Copyright 2014-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_LIB_H___
  13. #define ____MINERGATE_LIB_H___
  14. #include "config.h"
  15. //#include "squid.h"
  16. #include <stdio.h>
  17. #include <stdlib.h>
  18. #include <getopt.h>
  19. #include <fcntl.h>
  20. #include <sys/ioctl.h>
  21. #include <linux/types.h>
  22. #include <linux/spi/spidev.h>
  23. #include <netinet/in.h>
  24. //#include "queue.h"
  25. //#include "spond_debug.h"
  26. #include "miner.h"
  27. #include "util.h"
  28. #ifndef passert
  29. #define passert assert
  30. #endif
  31. #define MINERGATE_PROTOCOL_VERSION 6
  32. #define MINERGATE_SOCKET_FILE "/tmp/connection_pipe"
  33. typedef enum {
  34. //MINERGATE_DATA_ID_CONNECT = 1,
  35. MINERGATE_DATA_ID_DO_JOB_REQ = 2,
  36. MINERGATE_DATA_ID_DO_JOB_RSP = 3,
  37. } MINERGATE_DATA_ID;
  38. typedef struct {
  39. uint32_t work_id_in_sw;
  40. uint32_t difficulty;
  41. uint32_t timestamp;
  42. uint32_t mrkle_root;
  43. uint32_t midstate[8];
  44. uint8_t leading_zeroes;
  45. uint8_t ntime_limit;
  46. uint8_t ntime_offset;
  47. uint8_t resr1;
  48. } minergate_do_job_req;
  49. #define MAX_REQUESTS 100
  50. #define MAX_RESPONDS 300
  51. #define MINERGATE_TOTAL_QUEUE 300
  52. typedef struct {
  53. uint32_t work_id_in_sw;
  54. uint32_t mrkle_root; // to validate
  55. uint32_t winner_nonce[2];
  56. uint8_t ntime_offset;
  57. uint8_t res; // 0 = done, 1 = overflow, 2 = dropped bist
  58. uint8_t resrv1;
  59. uint8_t resrv2;
  60. } minergate_do_job_rsp;
  61. typedef struct {
  62. uint8_t requester_id;
  63. uint8_t request_id;
  64. uint8_t protocol_version;
  65. uint8_t mask; // 0x01 = first request, 0x2 = drop old work
  66. uint16_t magic; // 0xcafe
  67. uint16_t req_count;
  68. minergate_do_job_req req[MAX_REQUESTS]; // array of requests
  69. } minergate_req_packet;
  70. typedef struct {
  71. uint8_t requester_id;
  72. uint8_t request_id;
  73. uint8_t protocol_version;
  74. uint8_t gh_div_10_rate; // ==
  75. uint16_t magic; // 0xcafe
  76. uint16_t rsp_count;
  77. minergate_do_job_rsp rsp[MAX_RESPONDS]; // array of responce
  78. } minergate_rsp_packet;
  79. minergate_req_packet *allocate_minergate_packet_req(uint8_t requester_id, uint8_t request_id);
  80. minergate_rsp_packet *allocate_minergate_packet_rsp(uint8_t requester_id, uint8_t request_id);
  81. #endif