driver-spondoolies-sp10-p.h 2.3 KB

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