==> include/mesh/prog/sha256d.h <==1/* programs/sha256d's view layout and ops (mirrored by mesh-kcheck's sha checks).
2 * Ported from alpha-rust-mesh programs/sha256d/src/lib.rs. */
3#ifndef MESH_PROG_SHA256D_H
4#define MESH_PROG_SHA256D_H
5
6#define SHA_V_MAGIC 0x000u /* u32 "S256" */
7#define SHA_V_GEN 0x004u /* u32 config generation, odd while it is written */
8#define SHA_V_LOCK 0x008u /* u32 spin lock (results, config) */
9#define SHA_V_FOUND 0x00cu /* u32 1 once a share was found (since the header/target/reset) */
10#define SHA_V_HASHES 0x010u /* u64 hashes done (since reset) */
11/* 0x018: u64, free (was the OP_TASK chunk counter) */
12#define SHA_V_BASE 0x020u /* u32 nonce base */
13#define SHA_V_CHUNK_LOG2 0x024u /* u32 nonces per task = 1 << this */
14#define SHA_V_TARGET_ZBITS 0x028u /* u32 leading zero bits of the target */
15#define SHA_V_SHARES 0x02cu /* u32 shares found */
16#define SHA_V_BEST_ZBITS 0x030u /* u32 leading zero bits of the best hash */
17#define SHA_V_BEST_NONCE 0x034u
18#define SHA_V_BEST_TIME 0x038u /* ntime of the best hash (time + roll) */
19#define SHA_V_LAST_NONCE 0x03cu /* the last share */
20#define SHA_V_LAST_TIME 0x040u
21#define SHA_V_VERSION 0x044u /* header version (copy) */
22#define SHA_V_TIME 0x048u /* header time (copy) */
23#define SHA_V_NBITS 0x04cu /* header bits (copy) */
24#define SHA_V_BEST_HI 0x050u /* the best hash's top 32 bits (display order) */
25#define SHA_V_SYSTEM 0x054u /* system at the last chunk */
26#define SHA_V_HEADERS 0x058u /* header changes */
27#define SHA_V_LAST_ZBITS 0x05cu
28#define SHA_V_BEST 0x060u /* [u8; 32] best hash, internal order (all 0xff: none) */
29#define SHA_V_HEADER 0x080u /* [u8; 80] */
30#define SHA_V_TARGET 0x0d0u /* [u8; 32] internal order */
31#define SHA_V_MID 0x0f0u /* [u32; 8] midstate of the header's first block */
32#define SHA_V_STAGE 0x110u /* [u8; 112] request staging (header, target) */
33#define SHA_V_RING 0x200u /* RING x RING_BYTES: the last shares */
34#define SHA_RING 32u
35#define SHA_RING_BYTES 48u /* nonce, ntime, seq (1-based share number), zbits, hash [u8; 32] */
36/* u64: the job item base meshd writes (manifest job_base): OP_JOB grinds chunk V_JOB_BASE + arg. */
37#define SHA_V_JOB_BASE 0x1000u
38/* The items' result records (manifest job_out): JOB_REC bytes at V_JOB_OUT + JOB_REC (ticket % 64):
39 * shares u32, then JOB_SHARES x (nonce u32, zbits u32), then the chunk's ntime u32. */
40#define SHA_V_JOB_OUT 0x1800u
41#define SHA_JOB_REC 32u
42#define SHA_JOB_SHARES 3u
43#define SHA_VIEW_MIN 0x2000u
44#define SHA_MAGIC 0x36353253u /* "S256" */
45
46/* Nonces per lane per hot-loop iteration. */
47#define SHA_ILP 2u
48#define SHA_CHUNK_LOG2_MIN 6u /* 5 + trailing_zeros(ILP) */
49#define SHA_CHUNK_LOG2_MAX 24u
50#define SHA_ZBITS_DEFAULT 26u
51
52#define SHA_OP_ZBITS 3u
53#define SHA_OP_RESET 4u
54#define SHA_OP_NBITS 5u
55#define SHA_OP_GENESIS 6u
56/* Refused (R_BAD_OP): the chunk size is the manifest's param. */
57#define SHA_OP_CHUNK 7u
58#define SHA_OP_BASE 8u
59#define SHA_OP_TIME 9u
60
61#endif