]> git.zerfleddert.de Git - proxmark3-svn/blob - armsrc/apps.h
Extended iClass support with Card and Reader emulation!
[proxmark3-svn] / armsrc / apps.h
1 //-----------------------------------------------------------------------------
2 // Jonathan Westhues, Aug 2005
3 // Gerhard de Koning Gans, April 2008, May 2011
4 //
5 // This code is licensed to you under the terms of the GNU GPL, version 2 or,
6 // at your option, any later version. See the LICENSE.txt file for the text of
7 // the license.
8 //-----------------------------------------------------------------------------
9 // Definitions internal to the app source.
10 //-----------------------------------------------------------------------------
11
12 #ifndef __APPS_H
13 #define __APPS_H
14
15 #include <stdint.h>
16 #include <stddef.h>
17 typedef unsigned char byte_t;
18
19 // The large multi-purpose buffer, typically used to hold A/D samples,
20 // maybe processed in some way.
21 uint32_t BigBuf[8000];
22 extern const uint8_t OddByteParity[256];
23 extern uint8_t *trace; // = (uint8_t *) BigBuf;
24 extern int traceLen; // = 0;
25 extern int rsamples; // = 0;
26 extern int tracing; // = TRUE;
27 extern uint8_t trigger;
28
29 // This may be used (sparingly) to declare a function to be copied to
30 // and executed from RAM
31 #define RAMFUNC __attribute((long_call, section(".ramfunc")))
32
33 /// appmain.h
34 void ReadMem(int addr);
35 void __attribute__((noreturn)) AppMain(void);
36 void SamyRun(void);
37 //void DbpIntegers(int a, int b, int c);
38 void DbpString(char *str);
39 void Dbprintf(const char *fmt, ...);
40 void Dbhexdump(int len, uint8_t *d);
41
42 int AvgAdc(int ch);
43
44 void ToSendStuffBit(int b);
45 void ToSendReset(void);
46 void ListenReaderField(int limit);
47 void AcquireRawAdcSamples125k(int at134khz);
48 void DoAcquisition125k(void);
49 extern int ToSendMax;
50 extern uint8_t ToSend[];
51 extern uint32_t BigBuf[];
52
53 /// fpga.h
54 void FpgaSendCommand(uint16_t cmd, uint16_t v);
55 void FpgaWriteConfWord(uint8_t v);
56 void FpgaDownloadAndGo(void);
57 void FpgaGatherVersion(char *dst, int len);
58 void FpgaSetupSsc(void);
59 void SetupSpi(int mode);
60 void FpgaSetupSscDma(uint8_t *buf, int len);
61 void SetAdcMuxFor(uint32_t whichGpio);
62
63 // Definitions for the FPGA commands.
64 #define FPGA_CMD_SET_CONFREG (1<<12)
65 #define FPGA_CMD_SET_DIVISOR (2<<12)
66 // Definitions for the FPGA configuration word.
67 #define FPGA_MAJOR_MODE_LF_READER (0<<5)
68 #define FPGA_MAJOR_MODE_LF_SIMULATOR (1<<5)
69 #define FPGA_MAJOR_MODE_HF_READER_TX (2<<5)
70 #define FPGA_MAJOR_MODE_HF_READER_RX_XCORR (3<<5)
71 #define FPGA_MAJOR_MODE_HF_SIMULATOR (4<<5)
72 #define FPGA_MAJOR_MODE_HF_ISO14443A (5<<5)
73 #define FPGA_MAJOR_MODE_LF_PASSTHRU (6<<5)
74 #define FPGA_MAJOR_MODE_OFF (7<<5)
75 // Options for the HF reader, tx to tag
76 #define FPGA_HF_READER_TX_SHALLOW_MOD (1<<0)
77 // Options for the HF reader, correlating against rx from tag
78 #define FPGA_HF_READER_RX_XCORR_848_KHZ (1<<0)
79 #define FPGA_HF_READER_RX_XCORR_SNOOP (1<<1)
80 #define FPGA_HF_READER_RX_XCORR_QUARTER_FREQ (1<<2)
81 // Options for the HF simulated tag, how to modulate
82 #define FPGA_HF_SIMULATOR_NO_MODULATION (0<<0)
83 #define FPGA_HF_SIMULATOR_MODULATE_BPSK (1<<0)
84 #define FPGA_HF_SIMULATOR_MODULATE_212K (2<<0)
85 // Options for ISO14443A
86 #define FPGA_HF_ISO14443A_SNIFFER (0<<0)
87 #define FPGA_HF_ISO14443A_TAGSIM_LISTEN (1<<0)
88 #define FPGA_HF_ISO14443A_TAGSIM_MOD (2<<0)
89 #define FPGA_HF_ISO14443A_READER_LISTEN (3<<0)
90 #define FPGA_HF_ISO14443A_READER_MOD (4<<0)
91
92 /// lfops.h
93 void AcquireRawAdcSamples125k(int at134khz);
94 void ModThenAcquireRawAdcSamples125k(int delay_off,int period_0,int period_1,uint8_t *command);
95 void ReadTItag(void);
96 void WriteTItag(uint32_t idhi, uint32_t idlo, uint16_t crc);
97 void AcquireTiType(void);
98 void AcquireRawBitsTI(void);
99 void SimulateTagLowFrequency(int period, int gap, int ledcontrol);
100 void CmdHIDsimTAG(int hi, int lo, int ledcontrol);
101 void CmdHIDdemodFSK(int findone, int *high, int *low, int ledcontrol);
102 void SimulateTagLowFrequencyBidir(int divisor, int max_bitlen);
103 void CopyHIDtoT5567(int hi, int lo); // Clone an HID card to T5557/T5567
104 void WriteEM410x(uint32_t card, uint32_t id_hi, uint32_t id_lo);
105
106 /// iso14443.h
107 void SimulateIso14443Tag(void);
108 void AcquireRawAdcSamplesIso14443(uint32_t parameter);
109 void ReadSRI512Iso14443(uint32_t parameter);
110 void ReadSRIX4KIso14443(uint32_t parameter);
111 void ReadSTMemoryIso14443(uint32_t parameter,uint32_t dwLast);
112 void RAMFUNC SnoopIso14443(void);
113
114 /// iso14443a.h
115 void RAMFUNC SnoopIso14443a(void);
116 void SimulateIso14443aTag(int tagType, int TagUid); // ## simulate iso14443a tag
117 void ReaderIso14443a(UsbCommand * c, UsbCommand * ack);
118 // Also used in iclass.c
119 int LogTrace(const uint8_t * btBytes, int iLen, int iSamples, uint32_t dwParity, int bReader);
120 uint32_t GetParity(const uint8_t * pbtCmd, int iLen);
121 void iso14a_set_trigger(int enable);
122 void iso14a_clear_tracelen(void);
123 void iso14a_set_tracing(int enable);
124
125 // mifarecmd.h
126 void ReaderMifare(uint32_t parameter);
127 void MifareReadBlock(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *data);
128 void MifareReadSector(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain);
129 void MifareWriteBlock(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain);
130 void MifareNested(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain);
131 void MifareChkKeys(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain);
132 void Mifare1ksim(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain);
133 void MifareSetDbgLvl(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain);
134 void MifareEMemClr(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain);
135 void MifareEMemSet(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain);
136 void MifareEMemGet(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain);
137 void MifareECardLoad(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain);
138
139 /// iso15693.h
140 void RecordRawAdcSamplesIso15693(void);
141 void AcquireRawAdcSamplesIso15693(void);
142 void ReaderIso15693(uint32_t parameter); // Simulate an ISO15693 reader - greg
143 void SimTagIso15693(uint32_t parameter); // simulate an ISO15693 tag - greg
144 void BruteforceIso15693Afi(uint32_t speed); // find an AFI of a tag - atrox
145 void DirectTag15693Command(uint32_t datalen,uint32_t speed, uint32_t recv, uint8_t data[]); // send arbitrary commands from CLI - atrox
146 void SetDebugIso15693(uint32_t flag);
147
148 /// iclass.h
149 void RAMFUNC SnoopIClass(void);
150 void SimulateIClass(uint8_t arg0, uint8_t *datain);
151 void ReaderIClass(uint8_t arg0);
152
153 /// util.h
154
155 #endif
Impressum, Datenschutz