Merge pull request #2616 from jmichelp/fix14b
[RRG-proxmark3.git] / armsrc / BigBuf.h
blob2e905a45c01ea56a187c5817538e4bb952791274
1 //-----------------------------------------------------------------------------
2 // Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // See LICENSE.txt for the text of the license.
15 //-----------------------------------------------------------------------------
16 // BigBuf and functions to allocate/free parts of it.
17 //-----------------------------------------------------------------------------
19 #ifndef __BIGBUF_H
20 #define __BIGBUF_H
22 #include "common.h"
24 #define MAX_FRAME_SIZE 256 // maximum allowed ISO14443 frame
25 #define MAX_PARITY_SIZE ((MAX_FRAME_SIZE + 7) / 8)
26 #define MAX_MIFARE_FRAME_SIZE 18 // biggest Mifare frame is answer to a read (one block = 16 Bytes) + 2 Bytes CRC
27 #define MAX_MIFARE_PARITY_SIZE 3 // need 18 parity bits for the 18 Byte above. 3 Bytes are enough to store these
28 #define CARD_MEMORY_SIZE 4096
29 // For now we're storing FM11RF08S nonces in the upper 1k of CARD_MEMORY_SIZE
30 // but we might have to allocate extra space if one day we've to support sth like a FM11RF32S
31 #define CARD_MEMORY_RF08S_OFFSET 1024
33 //#define DMA_BUFFER_SIZE (512 + 256)
34 #define DMA_BUFFER_SIZE 512
36 // 8 data bits and 1 parity bit per payload byte, 1 correction bit, 1 SOC bit, 2 EOC bits
37 #define TOSEND_BUFFER_SIZE (9 * MAX_FRAME_SIZE + 1 + 1 + 2)
39 uint8_t *BigBuf_get_addr(void);
40 uint32_t BigBuf_get_size(void);
41 uint8_t *BigBuf_get_EM_addr(void);
42 uint16_t BigBuf_max_traceLen(void);
43 uint32_t BigBuf_get_hi(void);
45 void BigBuf_initialize(void);
46 void BigBuf_Clear(void);
47 void BigBuf_Clear_ext(bool verbose);
48 void BigBuf_Clear_keep_EM(void);
49 void BigBuf_Clear_EM(void);
50 uint8_t *BigBuf_malloc(uint16_t);
51 uint8_t *BigBuf_calloc(uint16_t);
52 void BigBuf_free(void);
53 void BigBuf_free_keep_EM(void);
54 void BigBuf_print_status(void);
55 uint32_t BigBuf_get_traceLen(void);
56 void clear_trace(void);
57 void set_tracing(bool enable);
58 void set_tracelen(uint32_t value);
59 bool get_tracing(void);
61 bool RAMFUNC LogTrace(const uint8_t *btBytes, uint16_t iLen, uint32_t timestamp_start, uint32_t timestamp_end, const uint8_t *parity, bool reader2tag);
62 bool RAMFUNC LogTraceBits(const uint8_t *btBytes, uint16_t bitLen, uint32_t timestamp_start, uint32_t timestamp_end, bool reader2tag);
63 bool LogTrace_ISO15693(const uint8_t *bytes, uint16_t len, uint32_t ts_start, uint32_t ts_end, const uint8_t *parity, bool reader2tag);
65 int emlSet(const uint8_t *data, uint32_t offset, uint32_t length);
66 int emlGet(uint8_t *out, uint32_t offset, uint32_t length);
68 typedef struct {
69 int max;
70 int bit;
71 uint8_t *buf;
72 } tosend_t;
74 tosend_t *get_tosend(void);
75 void tosend_reset(void);
76 void tosend_stuffbit(int b);
78 typedef struct {
79 uint16_t size;
80 uint8_t *buf;
81 } dmabuf8_t;
83 typedef struct {
84 uint16_t size;
85 uint16_t *buf;
86 } dmabuf16_t;
88 dmabuf8_t *get_dma8(void);
89 dmabuf16_t *get_dma16(void);
90 #endif /* __BIGBUF_H */