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