From: bg Date: Sat, 19 Oct 2013 03:45:58 +0000 (+0200) Subject: removing memory r/w/x features X-Git-Url: https://git.cryptolib.org/?p=labortage2013badge.git;a=commitdiff_plain;h=d6003d9a8f792c6e7198039e43693c36bf5f4550 removing memory r/w/x features --- diff --git a/firmware/main.c b/firmware/main.c index 056a762..6f756de 100644 --- a/firmware/main.c +++ b/firmware/main.c @@ -34,7 +34,6 @@ different port or bit, change the macros below: #include "usbdrv.h" #include "oddebug.h" /* This is also an example for using debug macros */ #include "requests.h" /* The custom request numbers we use */ -#include "special_functions.h" #include "hotp.h" #if !SIMPLE_COUNTER #include "percnt2.h" @@ -350,20 +349,6 @@ usbMsgLen_t usbFunctionSetup(uchar data[8]) usbMsgPtr = dbg_buffer; return len; } - case CUSTOM_RQ_READ_MEM: - usbMsgPtr = (uchar*)rq->wValue.word; - return rq->wLength.word; - case CUSTOM_RQ_WRITE_MEM: - case CUSTOM_RQ_EXEC_SPM: -/* uni_buffer_fill = 4; - uni_buffer.w16[0] = rq->wValue.word; - uni_buffer.w16[1] = rq->wLength.word; - return USB_NO_MSG; -*/ case CUSTOM_RQ_READ_FLASH: - uni_buffer.w16[0] = rq->wValue.word; - uni_buffer.w16[1] = rq->wLength.word; - uni_buffer_fill = 4; - return USB_NO_MSG; case CUSTOM_RQ_RESET: soft_reset((uint8_t)(rq->wValue.word)); break; @@ -404,46 +389,12 @@ uchar usbFunctionWrite(uchar *data, uchar len) } memcpy(dbg_buffer, data, len); return 1; - case CUSTOM_RQ_WRITE_MEM: - memcpy(uni_buffer.ptr[0], data, len); - uni_buffer.w16[0] += len; - return !(uni_buffer.w16[1] -= len); - case CUSTOM_RQ_EXEC_SPM: - if(uni_buffer_fill < 8){ - uint8_t l = 8 - uni_buffer_fill; - if(len 8) { - memcpy(uni_buffer.ptr[0], data, len); - uni_buffer.w16[0] += len; - return 0; - } else { - memcpy(&(uni_buffer.w8[uni_buffer_fill]), data, len); - exec_spm(uni_buffer.w16[2], uni_buffer.w16[3], uni_buffer.ptr[0], data, len); - return 1; - } default: return 1; } return 0; } uchar usbFunctionRead(uchar *data, uchar len){ - uchar ret = len; - switch(current_command){ - case CUSTOM_RQ_READ_FLASH: - while(len--){ - *data++ = pgm_read_byte((uni_buffer.w16[0])++); - } - return ret; - default: - break; - } return 0; } diff --git a/firmware/special_functions.S b/firmware/special_functions.S index 88ae6dc..d3c9c51 100644 --- a/firmware/special_functions.S +++ b/firmware/special_functions.S @@ -20,38 +20,6 @@ #include #include "usbconfig.h" -.global exec_spm -/* void exec_spm(uint16_t z, uint16_t r0r1, void* dest, void* src, uint8_t len); */ -exec_spm: - push r28 - push r29 - movw r30, r24 - movw r0, r22 - movw r28, r20 - movw r26, r18 - movw r24, r16 - in r23, _SFR_IO_ADDR(SREG) - cli - tst r24 - breq spm_cmd - dec r24 - breq last_store -copy_loop: - ld r22, X+ - st Y+, r22 - dec r24 - brne copy_loop -last_store: - ld r22, X+ - st Y+, r22 -spm_cmd: - spm - out _SFR_IO_ADDR(SREG), r23 - clr r1 - pop r29 - pop r28 - ret - .global soft_reset soft_reset: cli diff --git a/firmware/special_functions.h b/firmware/special_functions.h index a970e14..aa55bff 100644 --- a/firmware/special_functions.h +++ b/firmware/special_functions.h @@ -22,7 +22,6 @@ #include -void exec_spm(uint16_t z, uint16_t r0r1, void* dest, void* src, uint8_t len); void soft_reset(uint8_t delay); #endif /* SPECIAL_FUNCTIONS_H_ */