optimize: found a great source of optimization - however "BOOTLOADER_ADDRESS" must...
authorStephan Baerwolf <stephan.baerwolf@tu-ilmenau.de>
Tue, 31 Jul 2012 15:34:58 +0000 (17:34 +0200)
committerStephan Baerwolf <stephan.baerwolf@tu-ilmenau.de>
Tue, 31 Jul 2012 18:16:55 +0000 (18:16 +0000)
Signed-off-by: Stephan Baerwolf <stephan.baerwolf@tu-ilmenau.de>
firmware/main.c

index 9800ecf..94aa800 100644 (file)
@@ -251,48 +251,36 @@ uchar   isLast;
         uchar i;
         for(i = 0; i < len;){
 #if HAVE_BLB11_SOFTW_LOCKBIT
         uchar i;
         for(i = 0; i < len;){
 #if HAVE_BLB11_SOFTW_LOCKBIT
-           uint8_t allowWrite = (CURRENT_ADDRESS < (addr_t)(BOOTLOADER_ADDRESS));
+           if (CURRENT_ADDRESS >= (addr_t)(BOOTLOADER_ADDRESS)) {
 #if HAVE_BLB11_SOFTW_BACKDOOR
 #if HAVE_BLB11_SOFTW_BACKDOOR
-           if ((stayinloader >= 0x10) && (bootLoaderCondition())) allowWrite=1;
+             if (!((stayinloader >= 0x10) && (bootLoaderCondition()))) return 1;
+#else
+             return 1;
 #endif
 #endif
+           }
 #endif
 #if !HAVE_CHIP_ERASE
             if((currentAddress.w[0] & (SPM_PAGESIZE - 1)) == 0){    /* if page start: erase */
                 DBG1(0x33, 0, 0);
 #   ifndef NO_FLASH_WRITE
 #endif
 #if !HAVE_CHIP_ERASE
             if((currentAddress.w[0] & (SPM_PAGESIZE - 1)) == 0){    /* if page start: erase */
                 DBG1(0x33, 0, 0);
 #   ifndef NO_FLASH_WRITE
-#      if HAVE_BLB11_SOFTW_LOCKBIT
-               if (allowWrite) {
-#      endif
                 cli();
                 boot_page_erase(CURRENT_ADDRESS);   /* erase page */
                 sei();
                 boot_spm_busy_wait();               /* wait until page is erased */
                 cli();
                 boot_page_erase(CURRENT_ADDRESS);   /* erase page */
                 sei();
                 boot_spm_busy_wait();               /* wait until page is erased */
-#      if HAVE_BLB11_SOFTW_LOCKBIT
-               }
-#      endif           
 #   endif
             }
 #endif
             i += 2;
             DBG1(0x32, 0, 0);
 #   endif
             }
 #endif
             i += 2;
             DBG1(0x32, 0, 0);
-#      if HAVE_BLB11_SOFTW_LOCKBIT
-           if (allowWrite) {
-#      endif
             cli();
             boot_page_fill(CURRENT_ADDRESS, *(short *)data);
             sei();
             cli();
             boot_page_fill(CURRENT_ADDRESS, *(short *)data);
             sei();
-#      if HAVE_BLB11_SOFTW_LOCKBIT
-           }
-#      endif
             CURRENT_ADDRESS += 2;
             data += 2;
             /* write page when we cross page boundary or we have the last partial page */
             if((currentAddress.w[0] & (SPM_PAGESIZE - 1)) == 0 || (isLast && i >= len && isLastPage)){
                 DBG1(0x34, 0, 0);
 #ifndef NO_FLASH_WRITE
             CURRENT_ADDRESS += 2;
             data += 2;
             /* write page when we cross page boundary or we have the last partial page */
             if((currentAddress.w[0] & (SPM_PAGESIZE - 1)) == 0 || (isLast && i >= len && isLastPage)){
                 DBG1(0x34, 0, 0);
 #ifndef NO_FLASH_WRITE
-#      if HAVE_BLB11_SOFTW_LOCKBIT
-               if (allowWrite) {
-#      endif
                 cli();
                 boot_page_write(CURRENT_ADDRESS - 2);
                 sei();
                 cli();
                 boot_page_write(CURRENT_ADDRESS - 2);
                 sei();
@@ -300,9 +288,6 @@ uchar   isLast;
                 cli();
                 boot_rww_enable();
                 sei();
                 cli();
                 boot_rww_enable();
                 sei();
-#      if HAVE_BLB11_SOFTW_LOCKBIT
-               }
-#      endif
 #endif
             }
         }
 #endif
             }
         }