X-Git-Url: http://cvs.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/d52e4e881910964f151e0ea51dd5621e6ab6315e..e57fe796f529d3edd7d48f1fa51676e809531280:/armsrc/appmain.c diff --git a/armsrc/appmain.c b/armsrc/appmain.c index 33944c1d..00e9ba4d 100644 --- a/armsrc/appmain.c +++ b/armsrc/appmain.c @@ -20,7 +20,6 @@ #include "string.h" #include - #include "legicrf.h" #include "../include/hitag2.h" @@ -37,18 +36,12 @@ // is the order in which they go out on the wire. //============================================================================= -#define TOSEND_BUFFER_SIZE (9*MAX_FRAME_SIZE + 1 + 1 + 2) // 8 data bits and 1 parity bit per payload byte, 1 correction bit, 1 SOC bit, 2 EOC bits +#define TOSEND_BUFFER_SIZE (9*MAX_FRAME_SIZE + 1 + 1 + 2) // 8 data bits and 1 parity bit per payload byte, 1 correction bit, 1 SOC bit, 2 EOC bits uint8_t ToSend[TOSEND_BUFFER_SIZE]; int ToSendMax; static int ToSendBit; struct common_area common_area __attribute__((section(".commonarea"))); -void BufferClear(void) -{ - memset(BigBuf,0,sizeof(BigBuf)); - Dbprintf("Buffer cleared (%i bytes)",sizeof(BigBuf)); -} - void ToSendReset(void) { ToSendMax = -1; @@ -69,7 +62,7 @@ void ToSendStuffBit(int b) ToSendBit++; - if(ToSendMax >= sizeof(ToSend)) { + if(ToSendMax >= sizeof(ToSend)) { ToSendBit = 0; DbpString("ToSendStuffBit overflowed!"); } @@ -247,7 +240,10 @@ void MeasureAntennaTuningHf(void) void SimulateTagHfListen(void) { - uint8_t *dest = (uint8_t *)BigBuf+FREE_BUFFER_OFFSET; + // ToDo: historically this used the free buffer, which was 2744 Bytes long. + // There might be a better size to be defined: + #define HF_14B_SNOOP_BUFFER_SIZE 2744 + uint8_t *dest = BigBuf_malloc(HF_14B_SNOOP_BUFFER_SIZE); uint8_t v = 0; int i; int p = 0; @@ -282,7 +278,7 @@ void SimulateTagHfListen(void) p = 0; i++; - if(i >= FREE_BUFFER_SIZE) { + if(i >= HF_14B_SNOOP_BUFFER_SIZE) { break; } } @@ -656,6 +652,9 @@ void UsbPacketReceived(uint8_t *packet, int len) case CMD_IO_CLONE_TAG: CopyIOtoT55x7(c->arg[0], c->arg[1], c->d.asBytes[0]); break; + case CMD_EM410X_DEMOD: + CmdEM410xdemod(c->arg[0], 0, 0, 1); + break; case CMD_EM410X_WRITE_TAG: WriteEM410x(c->arg[0], c->arg[1], c->arg[2]); break; @@ -809,11 +808,11 @@ void UsbPacketReceived(uint8_t *packet, int len) MifareUC_Auth2(c->arg[0],c->d.asBytes); break; case CMD_MIFAREU_READCARD: - MifareUReadCard(c->arg[0],c->arg[1],c->d.asBytes); + MifareUReadCard(c->arg[0], c->arg[1], c->d.asBytes); break; case CMD_MIFAREUC_READCARD: - MifareUReadCard(c->arg[0],c->arg[1],c->d.asBytes); - break; + MifareUReadCard(c->arg[0], c->arg[1], c->d.asBytes); + break; case CMD_MIFARE_READSC: MifareReadSector(c->arg[0], c->arg[1], c->arg[2], c->d.asBytes); break; @@ -868,27 +867,6 @@ void UsbPacketReceived(uint8_t *packet, int len) case CMD_MIFARE_SNIFFER: SniffMifare(c->arg[0]); break; - - // mifare desfire - case CMD_MIFARE_DESFIRE_READBL: - break; - case CMD_MIFARE_DESFIRE_WRITEBL: - break; - case CMD_MIFARE_DESFIRE_AUTH1: - MifareDES_Auth1(c->arg[0], c->arg[1], c->arg[2], c->d.asBytes); - break; - case CMD_MIFARE_DESFIRE_AUTH2: - //MifareDES_Auth2(c->arg[0],c->d.asBytes); - break; - // case CMD_MIFARE_DES_READER: - // ReaderMifareDES(c->arg[0], c->arg[1], c->d.asBytes); - //break; - case CMD_MIFARE_DESFIRE_INFO: - MifareDesfireGetInformation(); - break; - case CMD_MIFARE_DESFIRE: - MifareSendCommand(c->arg[0], c->arg[1], c->d.asBytes); - break; #endif @@ -913,7 +891,7 @@ void UsbPacketReceived(uint8_t *packet, int len) break; case CMD_BUFF_CLEAR: - BufferClear(); + BigBuf_Clear(); break; case CMD_MEASURE_ANTENNA_TUNING: @@ -937,17 +915,18 @@ void UsbPacketReceived(uint8_t *packet, int len) case CMD_DOWNLOAD_RAW_ADC_SAMPLES_125K: LED_B_ON(); + uint8_t *BigBuf = BigBuf_get_addr(); for(size_t i=0; iarg[1]; i += USB_CMD_DATA_SIZE) { size_t len = MIN((c->arg[1] - i),USB_CMD_DATA_SIZE); - cmd_send(CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K,i,len,0,((byte_t*)BigBuf)+c->arg[0]+i,len); + cmd_send(CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K,i,len,traceLen,BigBuf+c->arg[0]+i,len); } // Trigger a finish downloading signal with an ACK frame - cmd_send(CMD_ACK,0,0,0,0,0); + cmd_send(CMD_ACK,0,0,traceLen,0,0); LED_B_OFF(); break; case CMD_DOWNLOADED_SIM_SAMPLES_125K: { - uint8_t *b = (uint8_t *)BigBuf; + uint8_t *b = BigBuf_get_addr(); memcpy(b+c->arg[0], c->d.asBytes, USB_CMD_DATA_SIZE); cmd_send(CMD_ACK,0,0,0,0,0); break;