]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - armsrc/appmain.c
Refactoring of BigBuf handling in order to prepare for more efficient memory allocati...
[proxmark3-svn] / armsrc / appmain.c
index 88ade8511b544a561eb8dc5f724706d6ff8f4415..a4d9c33549ab22e4913de79c9b7927eb7478ce07 100644 (file)
@@ -42,12 +42,6 @@ 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;
@@ -246,7 +240,7 @@ void MeasureAntennaTuningHf(void)
 
 void SimulateTagHfListen(void)
 {
-       uint8_t *dest = (uint8_t *)BigBuf+FREE_BUFFER_OFFSET;
+       uint8_t *dest = BigBuf_get_addr() + FREE_BUFFER_OFFSET;
        uint8_t v = 0;
        int i;
        int p = 0;
@@ -808,11 +802,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);
-                        break;
+                       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;
@@ -891,7 +885,7 @@ void UsbPacketReceived(uint8_t *packet, int len)
                        break;
 
                case CMD_BUFF_CLEAR:
-                       BufferClear();
+                       BigBuf_Clear();
                        break;
 
                case CMD_MEASURE_ANTENNA_TUNING:
@@ -915,9 +909,10 @@ 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; i<c->arg[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,0,BigBuf+c->arg[0]+i,len);
                        }
                        // Trigger a finish downloading signal with an ACK frame
                        cmd_send(CMD_ACK,0,0,0,0,0);
@@ -925,7 +920,7 @@ void UsbPacketReceived(uint8_t *packet, int len)
                        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;
Impressum, Datenschutz