- Replace 'if(' with 'if ('.
[fw/openocd] / src / jtag / zy1000 / zy1000.c
index ad148f1d6d7c6c6ff41bf713d7e0f7b3c8504aef..3425a4f06496dbc3ef530c366af138987959522f 100644 (file)
 #define ZYLIN_TIME __TIME__
 #define ZYLIN_OPENOCD "$Revision$"
 #define ZYLIN_OPENOCD_VERSION "Zylin JTAG ZY1000 " ZYLIN_VERSION " " ZYLIN_DATE " " ZYLIN_TIME
-const char *zylin_config_dir="/config/settings";
 
 /* low level command set
  */
-int zy1000_read(void);
-static void zy1000_write(int tck, int tms, int tdi);
 void zy1000_reset(int trst, int srst);
 
 
@@ -127,22 +124,10 @@ jtag_interface_t zy1000_interface =
        .srst_asserted = zy1000_srst_asserted,
 };
 
-static void zy1000_write(int tck, int tms, int tdi)
-{
-
-}
-
-int zy1000_read(void)
-{
-       return -1;
-}
-
-extern bool readSRST(void);
-
 void zy1000_reset(int trst, int srst)
 {
        LOG_DEBUG("zy1000 trst=%d, srst=%d", trst, srst);
-       if(!srst)
+       if (!srst)
        {
                ZY1000_POKE(ZY1000_JTAG_BASE+0x14, 0x00000001);
        }
@@ -154,7 +139,7 @@ void zy1000_reset(int trst, int srst)
                ZY1000_POKE(ZY1000_JTAG_BASE+0x10, 0x00000001);
        }
 
-       if(!trst)
+       if (!trst)
        {
                ZY1000_POKE(ZY1000_JTAG_BASE+0x14, 0x00000002);
        }
@@ -164,7 +149,7 @@ void zy1000_reset(int trst, int srst)
                ZY1000_POKE(ZY1000_JTAG_BASE+0x10, 0x00000002);
        }
 
-       if (trst||(srst&&(jtag_reset_config & RESET_SRST_PULLS_TRST)))
+       if (trst||(srst&&(jtag_get_reset_config() & RESET_SRST_PULLS_TRST)))
        {
                waitIdle();
                /* we're now in the RESET state until trst is deasserted */
@@ -203,7 +188,7 @@ void zy1000_reset(int trst, int srst)
 
 int zy1000_speed(int speed)
 {
-       if(speed == 0)
+       if (speed == 0)
        {
                /*0 means RCLK*/
                speed = 0;
@@ -212,7 +197,7 @@ int zy1000_speed(int speed)
        }
        else
        {
-               if(speed > 8190 || speed < 2)
+               if (speed > 8190 || speed < 2)
                {
                        LOG_USER("valid ZY1000 jtag_speed=[8190,2]. Divisor is 64MHz / even values between 8190-2, i.e. min 7814Hz, max 32MHz");
                        return ERROR_INVALID_ARGUMENTS;
@@ -356,7 +341,7 @@ int zy1000_init(void)
 
         /* deassert resets. Important to avoid infinite loop waiting for SRST to deassert */
        zy1000_reset(0, 0);
-       zy1000_speed(jtag_speed);
+       zy1000_speed(jtag_get_speed());
 
        return ERROR_OK;
 }
@@ -425,9 +410,9 @@ static void shiftValueInnerFlip(const tap_state_t state, const tap_state_t endSt
 }
 #endif
 
-extern int jtag_check_value(u8 *captured, void *priv);
+extern int jtag_check_value(uint8_t *captured, void *priv);
 
-static __inline void scanFields(int num_fields, scan_field_t *fields, tap_state_t shiftState, tap_state_t end_state)
+static __inline void scanFields(int num_fields, const scan_field_t *fields, tap_state_t shiftState, tap_state_t end_state)
 {
        int i;
        int j;
@@ -437,9 +422,7 @@ static __inline void scanFields(int num_fields, scan_field_t *fields, tap_state_
        {
                cyg_uint32 value;
 
-               static u8 *in_buff=NULL; /* pointer to buffer for scanned data */
-               static int in_buff_size=0;
-               u8 *inBuffer=NULL;
+               uint8_t *inBuffer=NULL;
 
 
                // figure out where to store the input data
@@ -478,7 +461,7 @@ static __inline void scanFields(int num_fields, scan_field_t *fields, tap_state_
                                }
                        }
                        /* mask away unused bits for easier debugging */
-                       value&=~(((u32)0xffffffff)<<k);
+                       value&=~(((uint32_t)0xffffffff)<<k);
 
                        shiftValueInner(shiftState, pause_state, k, value);
 
@@ -546,7 +529,7 @@ int interface_jtag_add_ir_scan(int num_fields, const scan_field_t *fields, tap_s
                if (!found)
                {
                        /* if a device isn't listed, set it to BYPASS */
-                       u8 ones[]={0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
+                       uint8_t ones[]={0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
 
                        scan_field_t tmp;
                        memset(&tmp, 0, sizeof(tmp));
@@ -669,7 +652,7 @@ static int zy1000_jtag_add_clocks(int num_cycles, tap_state_t state, tap_state_t
        tap_state_t t=TAP_IDLE;
        /* test manual drive code on any target */
        int tms;
-       u8 tms_scan = tap_get_tms_path(t, state);
+       uint8_t tms_scan = tap_get_tms_path(t, state);
        int tms_count = tap_get_tms_path_len(tap_get_state(), tap_get_end_state());
 
        for (i = 0; i < tms_count; i++)
@@ -696,7 +679,7 @@ int interface_jtag_add_clocks(int num_cycles)
        return zy1000_jtag_add_clocks(num_cycles, cmd_queue_cur_state, cmd_queue_cur_state);
 }
 
-int interface_jtag_add_sleep(u32 us)
+int interface_jtag_add_sleep(uint32_t us)
 {
        jtag_sleep(us);
        return ERROR_OK;
@@ -745,7 +728,7 @@ int interface_jtag_add_pathmove(int num_states, const tap_state_t *path)
 
 
 
-void embeddedice_write_dcc(jtag_tap_t *tap, int reg_addr, u8 *buffer, int little, int count)
+void embeddedice_write_dcc(jtag_tap_t *tap, int reg_addr, uint8_t *buffer, int little, int count)
 {
 //     static int const reg_addr=0x5;
        tap_state_t end_state=jtag_get_end_state();
@@ -783,27 +766,4 @@ void embeddedice_write_dcc(jtag_tap_t *tap, int reg_addr, u8 *buffer, int little
        }
 }
 
-int loadFile(const char *fileName, void **data, int *len);
-
-/* boolean parameter stored on config */
-int boolParam(char *var)
-{
-       bool result = false;
-       char *name = alloc_printf("%s/%s", zylin_config_dir, var);
-       if (name == NULL)
-               return result;
-
-       void *data;
-       int len;
-       if (loadFile(name, &data, &len) == ERROR_OK)
-       {
-               if (len > 1)
-                       len = 1;
-               result = strncmp((char *) data, "1", len) == 0;
-               free(data);
-       }
-       free(name);
-       return result;
-}
-