Author: kosmo                        Date: Thu Aug 20 10:01:44 2009 GMT
Module: packages                      Tag: HEAD
---- Log message:
- added openocd-svf-handle-blank.patch which makes OpenOCD compatible with
  SVF files generated by Altera Quartus II v9.0.

---- Files affected:
packages/openocd:
   openocd.spec (1.3 -> 1.4) , openocd-svf-handle-blank.patch (NONE -> 1.1)  
(NEW)

---- Diffs:

================================================================
Index: packages/openocd/openocd.spec
diff -u packages/openocd/openocd.spec:1.3 packages/openocd/openocd.spec:1.4
--- packages/openocd/openocd.spec:1.3   Wed Aug 12 12:09:54 2009
+++ packages/openocd/openocd.spec       Thu Aug 20 12:01:38 2009
@@ -9,6 +9,7 @@
 Source0:       http://download.berlios.de/%{name}/%{name}-%{version}.tar.bz2
 # Source0-md5: 14cd477f65cc738be954a454f1593879
 Patch0:                %{name}-davinci-nand-cs.patch
+Patch1:                %{name}-svf-handle-blank.patch
 URL:           http://openocd.berlios.de/
 BuildRequires: autoconf
 BuildRequires: automake
@@ -37,6 +38,7 @@
 %prep
 %setup -q
 %patch0 -p1
+%patch1 -p1
 
 %build
 %{__libtoolize}
@@ -88,6 +90,10 @@
 All persons listed below can be reached at <cvs_login>@pld-linux.org
 
 $Log$
+Revision 1.4  2009/08/20 10:01:38  kosmo
+- added openocd-svf-handle-blank.patch which makes OpenOCD compatible with
+  SVF files generated by Altera Quartus II v9.0.
+
 Revision 1.3  2009/08/12 10:09:54  kosmo
 - added openocd-davinci-nand-cs.patch fixing DaVinci NAND driver.
 

================================================================
Index: packages/openocd/openocd-svf-handle-blank.patch
diff -u /dev/null packages/openocd/openocd-svf-handle-blank.patch:1.1
--- /dev/null   Thu Aug 20 12:01:44 2009
+++ packages/openocd/openocd-svf-handle-blank.patch     Thu Aug 20 12:01:37 2009
@@ -0,0 +1,144 @@
+From ae98eaa9ba23fce3ff8465d4892abcc2a6cdcfab Mon Sep 17 00:00:00 2001
+From: Piotr Ziecik <[email protected]>
+Date: Thu, 20 Aug 2009 09:56:16 +0200
+Subject: [PATCH] svf: Allow blank characters beetween hex digits.
+
+This patch adds handling blank characters between hex digits in
+SVF file, making OpenOCD compatible with files generated by
+Altera Quatrus II 9.0.
+
+Signed-off-by: Piotr Ziecik <[email protected]>
+---
+ src/svf/svf.c |   97 ++++++++++++++++++++++----------------------------------
+ 1 files changed, 38 insertions(+), 59 deletions(-)
+
+diff --git a/src/svf/svf.c b/src/svf/svf.c
+index 51edada..510b7b0 100644
+--- a/src/svf/svf.c
++++ b/src/svf/svf.c
+@@ -655,8 +655,8 @@ static int svf_adjust_array_length(uint8_t **arr, int 
orig_bit_len, int new_bit_
+ 
+ static int svf_copy_hexstring_to_binary(char *str, uint8_t **bin, int 
orig_bit_len, int bit_len)
+ {
+-      int i, str_len = strlen(str), str_byte_len = (bit_len + 3) >> 2, 
loop_cnt;
+-      uint8_t ch, need_write = 1;
++      int i, str_len = strlen(str), str_hbyte_len = (bit_len + 3) >> 2;
++      uint8_t ch;
+ 
+       if (ERROR_OK != svf_adjust_array_length(bin, orig_bit_len, bit_len))
+       {
+@@ -664,75 +664,54 @@ static int svf_copy_hexstring_to_binary(char *str, 
uint8_t **bin, int orig_bit_l
+               return ERROR_FAIL;
+       }
+ 
+-      if (str_byte_len > str_len)
++      for (i = 0; i < str_hbyte_len; i++)
+       {
+-              loop_cnt = str_byte_len;
+-      }
+-      else
+-      {
+-              loop_cnt = str_len;
+-      }
+-
+-      for (i = 0; i < loop_cnt; i++)
+-      {
+-              if (i < str_len)
++              ch = 0;
++              while (str_len > 0)
+               {
+-                      ch = str[str_len - i - 1];
+-                      if ((ch >= '0') && (ch <= '9'))
+-                      {
+-                              ch = ch - '0';
+-                      }
+-                      else if ((ch >= 'A') && (ch <= 'F'))
+-                      {
+-                              ch = ch - 'A' + 10;
+-                      }
+-                      else
++                      ch = str[--str_len];
++
++                      if (!isblank(ch))
+                       {
+-                              LOG_ERROR("invalid hex string");
+-                              return ERROR_FAIL;
++                              if ((ch >= '0') && (ch <= '9'))
++                              {
++                                      ch = ch - '0';
++                                      break;
++                              }
++                              else if ((ch >= 'A') && (ch <= 'F'))
++                              {
++                                      ch = ch - 'A' + 10;
++                                      break;
++                              }
++                              else
++                              {
++                                      LOG_ERROR("invalid hex string");
++                                      return ERROR_FAIL;
++                              }
+                       }
+-              }
+-              else
+-              {
++
+                       ch = 0;
+               }
+ 
+-              // check valid
+-              if (i >= str_byte_len)
++              // write bin
++              if (i % 2)
+               {
+-                      // all data written, other data should be all '0's and 
needn't to be written
+-                      need_write = 0;
+-                      if (ch != 0)
+-                      {
+-                              LOG_ERROR("value execede length");
+-                              return ERROR_FAIL;
+-                      }
++                      // MSB
++                      (*bin)[i / 2] |= ch << 4;
+               }
+-              else if (i == (str_byte_len - 1))
++              else
+               {
+-                      // last data byte, written if valid
+-                      if ((ch & ~((1 << (bit_len - 4 * i)) - 1)) != 0)
+-                      {
+-                              LOG_ERROR("value execede length");
+-                              return ERROR_FAIL;
+-                      }
++                      // LSB
++                      (*bin)[i / 2] = 0;
++                      (*bin)[i / 2] |= ch;
+               }
++      }
+ 
+-              if (need_write)
+-              {
+-                      // write bin
+-                      if (i % 2)
+-                      {
+-                              // MSB
+-                              (*bin)[i / 2] |= ch << 4;
+-                      }
+-                      else
+-                      {
+-                              // LSB
+-                              (*bin)[i / 2] = 0;
+-                              (*bin)[i / 2] |= ch;
+-                      }
+-              }
++      // check valid
++      if (str_len > 0 || (ch & ~((1 << (4 - (bit_len % 4))) - 1)) != 0)
++      {
++              LOG_ERROR("value execede length");
++              return ERROR_FAIL;
+       }
+ 
+       return ERROR_OK;
+-- 
+1.6.4
+
================================================================

---- CVS-web:
    
http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/openocd/openocd.spec?r1=1.3&r2=1.4&f=u

_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to