X-Git-Url: http://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/dcc10e5e310a9e652e698593b7ba34bacbdd2b80..249deb42a0e044337a14f74d0a032b340aaaf68b:/armsrc/appmain.c diff --git a/armsrc/appmain.c b/armsrc/appmain.c index fb501304..84b0954e 100644 --- a/armsrc/appmain.c +++ b/armsrc/appmain.c @@ -69,8 +69,8 @@ void DbpString(char *str) UsbCommand c; c.cmd = CMD_DEBUG_PRINT_STRING; - c.ext1 = strlen(str); - memcpy(c.d.asBytes, str, c.ext1); + c.arg[0] = strlen(str); + memcpy(c.d.asBytes, str, c.arg[0]); UsbSendPacket((BYTE *)&c, sizeof(c)); // TODO fix USB so stupid things like this aren't req'd @@ -85,9 +85,9 @@ void DbpIntegers(int x1, int x2, int x3) UsbCommand c; c.cmd = CMD_DEBUG_PRINT_INTEGERS; - c.ext1 = x1; - c.ext2 = x2; - c.ext3 = x3; + c.arg[0] = x1; + c.arg[1] = x2; + c.arg[2] = x3; UsbSendPacket((BYTE *)&c, sizeof(c)); // XXX @@ -176,9 +176,9 @@ void MeasureAntennaTuning(void) vHf = (33000 * AvgAdc(ADC_CHAN_HF)) >> 10; c.cmd = CMD_MEASURED_ANTENNA_TUNING; - c.ext1 = (vLf125 << 0) | (vLf134 << 16); - c.ext2 = vHf; - c.ext3 = peakf | (peakv << 16); + c.arg[0] = (vLf125 << 0) | (vLf134 << 16); + c.arg[1] = vHf; + c.arg[2] = peakf | (peakv << 16); UsbSendPacket((BYTE *)&c, sizeof(c)); } @@ -267,6 +267,7 @@ void SendVersion(void) DbpString(temp); } +#ifdef WITH_LF // samy's sniff and repeat routine void SamyRun() { @@ -377,7 +378,7 @@ void SamyRun() } } } - +#endif /* OBJECTIVE @@ -533,65 +534,92 @@ void UsbPacketReceived(BYTE *packet, int len) UsbCommand *c = (UsbCommand *)packet; switch(c->cmd) { +#ifdef WITH_LF case CMD_ACQUIRE_RAW_ADC_SAMPLES_125K: - AcquireRawAdcSamples125k(c->ext1); + AcquireRawAdcSamples125k(c->arg[0]); break; +#endif +#ifdef WITH_LF case CMD_MOD_THEN_ACQUIRE_RAW_ADC_SAMPLES_125K: - ModThenAcquireRawAdcSamples125k(c->ext1,c->ext2,c->ext3,c->d.asBytes); + ModThenAcquireRawAdcSamples125k(c->arg[0],c->arg[1],c->arg[2],c->d.asBytes); break; +#endif +#ifdef WITH_ISO15693 case CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_15693: AcquireRawAdcSamplesIso15693(); break; +#endif case CMD_BUFF_CLEAR: BufferClear(); break; +#ifdef WITH_ISO15693 case CMD_READER_ISO_15693: - ReaderIso15693(c->ext1); + ReaderIso15693(c->arg[0]); break; +#endif case CMD_READER_LEGIC_RF: LegicRfReader(); break; +#ifdef WITH_ISO15693 case CMD_SIMTAG_ISO_15693: - SimTagIso15693(c->ext1); + SimTagIso15693(c->arg[0]); break; +#endif +#ifdef WITH_ISO14443b case CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_14443: - AcquireRawAdcSamplesIso14443(c->ext1); + AcquireRawAdcSamplesIso14443(c->arg[0]); break; +#endif +#ifdef WITH_ISO14443b case CMD_READ_SRI512_TAG: - ReadSRI512Iso14443(c->ext1); + ReadSRI512Iso14443(c->arg[0]); break; + case CMD_READ_SRIX4K_TAG: + ReadSRIX4KIso14443(c->arg[0]); + break; +#endif +#ifdef WITH_ISO14443a case CMD_READER_ISO_14443a: - ReaderIso14443a(c->ext1); + ReaderIso14443a(c->arg[0]); break; +#endif +#ifdef WITH_ISO14443b case CMD_SNOOP_ISO_14443: SnoopIso14443(); break; +#endif +#ifdef WITH_ISO14443a case CMD_SNOOP_ISO_14443a: SnoopIso14443a(); break; +#endif case CMD_SIMULATE_TAG_HF_LISTEN: SimulateTagHfListen(); break; +#ifdef WITH_ISO14443b case CMD_SIMULATE_TAG_ISO_14443: SimulateIso14443Tag(); break; +#endif +#ifdef WITH_ISO14443a case CMD_SIMULATE_TAG_ISO_14443a: - SimulateIso14443aTag(c->ext1, c->ext2); // ## Simulate iso14443a tag - pass tag type & UID + SimulateIso14443aTag(c->arg[0], c->arg[1]); // ## Simulate iso14443a tag - pass tag type & UID break; +#endif case CMD_SIMULATE_TAG_LEGIC_RF: LegicRfSimulate(); @@ -602,16 +630,20 @@ void UsbPacketReceived(BYTE *packet, int len) break; case CMD_LISTEN_READER_FIELD: - ListenReaderField(c->ext1); + ListenReaderField(c->arg[0]); break; +#ifdef WITH_LF case CMD_HID_DEMOD_FSK: CmdHIDdemodFSK(0, 0, 0, 1); // Demodulate HID tag break; +#endif +#ifdef WITH_LF case CMD_HID_SIM_TAG: - CmdHIDsimTAG(c->ext1, c->ext2, 1); // Simulate HID tag by ID + CmdHIDsimTAG(c->arg[0], c->arg[1], 1); // Simulate HID tag by ID break; +#endif case CMD_FPGA_MAJOR_MODE_OFF: // ## FPGA Control FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); @@ -619,13 +651,17 @@ void UsbPacketReceived(BYTE *packet, int len) LED_D_OFF(); // LED D indicates field ON or OFF break; +#ifdef WITH_LF case CMD_READ_TI_TYPE: ReadTItag(); break; +#endif +#ifdef WITH_LF case CMD_WRITE_TI_TYPE: - WriteTItag(c->ext1,c->ext2,c->ext3); + WriteTItag(c->arg[0],c->arg[1],c->arg[2]); break; +#endif case CMD_DOWNLOAD_RAW_ADC_SAMPLES_125K: { UsbCommand n; @@ -634,47 +670,59 @@ void UsbPacketReceived(BYTE *packet, int len) } else { n.cmd = CMD_DOWNLOADED_RAW_BITS_TI_TYPE; } - n.ext1 = c->ext1; - memcpy(n.d.asDwords, BigBuf+c->ext1, 12*sizeof(DWORD)); + n.arg[0] = c->arg[0]; + memcpy(n.d.asDwords, BigBuf+c->arg[0], 12*sizeof(DWORD)); UsbSendPacket((BYTE *)&n, sizeof(n)); break; } + case CMD_DOWNLOADED_SIM_SAMPLES_125K: { BYTE *b = (BYTE *)BigBuf; - memcpy(b+c->ext1, c->d.asBytes, 48); + memcpy(b+c->arg[0], c->d.asBytes, 48); break; } + +#ifdef WITH_LF case CMD_SIMULATE_TAG_125K: LED_A_ON(); - SimulateTagLowFrequency(c->ext1, 1); + SimulateTagLowFrequency(c->arg[0], 1); LED_A_OFF(); break; +#endif + case CMD_READ_MEM: - ReadMem(c->ext1); + ReadMem(c->arg[0]); break; + case CMD_SET_LF_DIVISOR: - FpgaSendCommand(FPGA_CMD_SET_DIVISOR, c->ext1); + FpgaSendCommand(FPGA_CMD_SET_DIVISOR, c->arg[0]); break; + case CMD_SET_ADC_MUX: - switch(c->ext1) { - case 0: SetAdcMuxFor(GPIO_MUXSEL_LOPKD); break; - case 1: SetAdcMuxFor(GPIO_MUXSEL_LORAW); break; - case 2: SetAdcMuxFor(GPIO_MUXSEL_HIPKD); break; - case 3: SetAdcMuxFor(GPIO_MUXSEL_HIRAW); break; + switch(c->arg[0]) { + case 0: SetAdcMuxFor(GPIO_MUXSEL_LOPKD); break; + case 1: SetAdcMuxFor(GPIO_MUXSEL_LORAW); break; + case 2: SetAdcMuxFor(GPIO_MUXSEL_HIPKD); break; + case 3: SetAdcMuxFor(GPIO_MUXSEL_HIRAW); break; } break; + case CMD_VERSION: SendVersion(); break; + +#ifdef WITH_LF case CMD_LF_SIMULATE_BIDIR: - SimulateTagLowFrequencyBidir(c->ext1, c->ext2); + SimulateTagLowFrequencyBidir(c->arg[0], c->arg[1]); break; +#endif + #ifdef WITH_LCD case CMD_LCD_RESET: LCDReset(); break; case CMD_LCD: - LCDSend(c->ext1); + LCDSend(c->arg[0]); break; #endif case CMD_SETUP_WRITE: @@ -688,6 +736,7 @@ void UsbPacketReceived(BYTE *packet, int len) // We're going to reset, and the bootrom will take control. } break; + case CMD_START_FLASH: if(common_area.flags.bootrom_present) { common_area.command = COMMON_AREA_COMMAND_ENTER_FLASH_MODE; @@ -700,8 +749,8 @@ void UsbPacketReceived(BYTE *packet, int len) case CMD_DEVICE_INFO: { UsbCommand c; c.cmd = CMD_DEVICE_INFO; - c.ext1 = DEVICE_INFO_FLAG_OSIMAGE_PRESENT | DEVICE_INFO_FLAG_CURRENT_MODE_OS; - if(common_area.flags.bootrom_present) c.ext1 |= DEVICE_INFO_FLAG_BOOTROM_PRESENT; + c.arg[0] = DEVICE_INFO_FLAG_OSIMAGE_PRESENT | DEVICE_INFO_FLAG_CURRENT_MODE_OS; + if(common_area.flags.bootrom_present) c.arg[0] |= DEVICE_INFO_FLAG_BOOTROM_PRESENT; UsbSendPacket((BYTE*)&c, sizeof(c)); } break; @@ -777,7 +826,9 @@ void __attribute__((noreturn)) AppMain(void) UsbPoll(FALSE); WDT_HIT(); +#ifdef WITH_LF if (BUTTON_HELD(1000) > 0) SamyRun(); +#endif } }