Index: rsp-rtl_sim.h
===================================================================
--- rsp-rtl_sim.h	(révision 850)
+++ rsp-rtl_sim.h	(copie de travail)
@@ -53,13 +53,15 @@
 #if DEBUG==1
 #define debug printf
 #else
-#define debug
+#define debug(format, arg...) \
+        ({ if (0) printf(format, ##arg); 0; })
 #endif
 
 #if DEBUG2==1
 #define debug2 printf
 #else
-#define debug2
+#define debug2(format, arg...) \
+        ({ if (0) printf(format, ##arg); 0; })
 #endif
 
 
Index: gdb.h
===================================================================
--- gdb.h	(révision 850)
+++ gdb.h	(copie de travail)
@@ -49,6 +49,10 @@
 #ifndef GDB_H
 #define GDB_H
 
+#if (__GNUC__ == 4 && __GNUC_MINOR__ == 4)
+#pragma GCC diagnostic ignored "-Warray-bounds"
+#endif 
+
 #include <sys/types.h>
 #include <inttypes.h>
 
@@ -204,5 +208,6 @@
   int32_t status;
 } JTAGProxyChainResponse;
 
+void set_rsp_server_port(int portNum);
 
 #endif /* GDB_H */
Index: jp_vpi.c
===================================================================
--- jp_vpi.c	(révision 850)
+++ jp_vpi.c	(copie de travail)
@@ -225,29 +225,18 @@
 static pid_t rsp_server_child_pid = (pid_t) 0; // pid_t is just a signed int
 
 
-/********************************************************************/
-/* init_rsp_server
+/********************************************************************
+ * init_rsp_server
  * 
  * Fork off the rsp server process
- *                                                                   /
-/********************************************************************/
+ *
+ ********************************************************************
+ */
 void init_rsp_server(){
 
 
   // First get the port number to start the RSP server on
-  
-  vpiHandle systfref, args_iter, argh;
-  
-  struct t_vpi_value argval;
 
-  int value,i;
-
-  int n;
-
-  int portNum;
-  
-  char* send_buf;
-
   /*
 
   // Currently removed - ability to call $rsp_init_server() with a 
@@ -280,22 +269,21 @@
 
   // Fork. Let the child run the RSP server
   pid_t pid;
-  int rv;
 
   if(DBG_JP_VPI) printf("jp_vpi: init_rsp_server\n");
 
   // Setup pipes
-  if(pipe(vpi_to_rsp_pipe) == -1)
+  if(pipe((int *)vpi_to_rsp_pipe) == -1)
     {
       perror("jp_vpi: init_rsp_server pipes");
       exit(1);
     }
-  if(pipe(rsp_to_vpi_pipe) == -1)
+  if(pipe((int *)rsp_to_vpi_pipe) == -1)
     {
       perror("jp_vpi: init_rsp_server pipes");
       exit(1);
     }
-  if(pipe(command_pipe) == -1)
+  if(pipe((int *)command_pipe) == -1)
     {
       perror("jp_vpi: init_rsp_server pipes");
       exit(1);
@@ -414,8 +402,6 @@
 
   struct t_vpi_value argval;
 
-  int value,i;
-
   int n;
 
   unsigned char data;
@@ -485,8 +471,6 @@
 
   struct t_vpi_value argval;
 
-  int value,i;
-
   int n;
 
   uint32_t data;
@@ -539,8 +523,6 @@
 
   struct t_vpi_value argval;
 
-  int value,i;
-
   int n = 0;
 
   uint32_t data;
@@ -594,8 +576,6 @@
 
   struct t_vpi_value argval;
 
-  int value,i;
-
   int n;
 
   uint32_t data;
@@ -700,8 +680,6 @@
 
   struct t_vpi_value argval;
 
-  int value,i;
-
   int n, length;
 
   uint32_t data;
@@ -756,8 +734,6 @@
 
   struct t_vpi_value argval;
 
-  int value,i;
-
   int n;
 
   uint32_t data;
Index: rsp-rtl_sim.c
===================================================================
--- rsp-rtl_sim.c	(révision 850)
+++ rsp-rtl_sim.c	(copie de travail)
@@ -65,17 +65,6 @@
 /* The chain that should be currently selected. */
 static int dbg_chain = -1;
 
-/* Crc of current read or written data.  */
-static int crc_r, crc_w = 0;
-
-/* Generates new crc, sending in new bit input_bit */
-static uint32_t crc_calc(uint32_t crc, int input_bit) {
-  uint32_t d = (input_bit&1) ? 0xfffffff : 0x0000000;
-  uint32_t crc_32 = ((crc >> 31)&1) ? 0xfffffff : 0x0000000;
-  crc <<= 1;
-  return crc ^ (d ^ crc_32) & DBG_CRC_POLY;
-}
-
 /* VPI communication prototyopes */
 static void get_response_from_vpi();
 static void get_word_from_vpi();
@@ -98,11 +87,11 @@
   //n = write(rsp_to_vpi_pipe[1],&CMD, 1); // send the command to the sim
   n = write(command_pipe[1],&CMD, 1); // send the command to the sim
   
-  if (n < 0)   error("ERROR writing to VPI FIFO");
+  if (n < 0)   perror("ERROR writing to VPI FIFO");
   
   n = read(vpi_to_rsp_pipe[0],&cmd_resp,1); // block and wait for the ack
   
-  if (cmd_resp != CMD) error("Response from RTL sim incorrect"); //check it acked with cmd
+  if (cmd_resp != CMD) perror("Response from RTL sim incorrect"); //check it acked with cmd
 
   return;
 }
@@ -120,7 +109,7 @@
   
   n = write(rsp_to_vpi_pipe[1],send_buf, 4); // send the address to the sim
   
-  if (n < 0)   error("ERROR writing to VPI socket");
+  if (n < 0)   perror("ERROR writing to VPI socket");
   
   return;
 }
@@ -138,7 +127,7 @@
   
   n = write(rsp_to_vpi_pipe[1],send_buf, 4); // Write the data to the socket
   
-  if (n < 0)   error("ERROR writing to VPI socket");
+  if (n < 0)   perror("ERROR writing to VPI socket");
   
   return;
   
@@ -147,7 +136,7 @@
 void send_block_data_to_vpi(int len, uint32_t *data)
 {
   // Now send data
-  int n, i;
+  int n;
   
   char* send_buf;
 
@@ -157,7 +146,7 @@
   
   n = write(rsp_to_vpi_pipe[1],send_buf, len); // Write the data to the fifo
   
-  if (n < 0)   error("ERROR writing to VPI socket");
+  if (n < 0)   perror("ERROR writing to VPI socket");
   
   return;
   
@@ -210,11 +199,7 @@
 {
   int n, i, status;
   
-  uint32_t inc_data;
-  
   char* recv_buf;
-
-  uint32_t* data_ptr;
   
   recv_buf = (char *) data;
 
@@ -266,7 +251,6 @@
 }
 
 static void jp2_reset_JTAG() {
-  int i;
 
   debug2("\nreset(");
 
@@ -281,7 +265,6 @@
 /* Resets JTAG, and sets DEBUG scan chain */
  int dbg_reset() {
    
-   int err;
    uint32_t id;
    
    jp2_reset_JTAG();
@@ -318,7 +301,6 @@
 /* TODO: dinamically adjust timings for jp2 */
 static int retry_no = 0;
 int retry_do() {
-  int i, err;
   printf("RETRY\n");
   //exit(2);
   if (retry_no >= NUM_SOFT_RETRIES) {
@@ -637,28 +619,26 @@
 
 /* write a cpu module register */
 int dbg_cpu0_write_ctrl(uint32_t adr, unsigned char data) {
-  int err;
-  if ((err = dbg_set_chain(DC_CPU0))) return err;
-  if ((err = dbg_ctrl(data & 2, data &1))) return err;
+  int ret;
+  if ((ret = dbg_set_chain(DC_CPU0))) return ret;
+  if ((ret = dbg_ctrl(data & 2, data &1))) return ret;
   return DBG_ERR_OK;
 }
 
 /* read a register from cpu module */
 int dbg_cpu0_read_ctrl(uint32_t adr, unsigned char *data) {
-  int err;
+  int ret;
   int r, s;
-  if ((err = dbg_set_chain(DC_CPU0))) return err;
-  if ((err = dbg_ctrl_read(&r, &s))) return err;
+  if ((ret = dbg_set_chain(DC_CPU0))) return ret;
+  if ((ret = dbg_ctrl_read(&r, &s))) return ret;
   *data = (r << 1) | s;
   return DBG_ERR_OK;
 }
 
 void dbg_test() {
-  int i;
-  uint32_t npc, ppc, r1, insn, result;
+
+  uint32_t r1;
   unsigned char stalled;
-  //	uint32_t stalled;
-  unsigned char read_byte;
 
   printf("  Stall or1k\n");
   dbg_cpu0_write_ctrl(0, 0x01);      // stall or1k
Index: gdb.c
===================================================================
--- gdb.c	(révision 850)
+++ gdb.c	(copie de travail)
@@ -310,8 +310,6 @@
 int server_fd = 0;
 int gdb_fd = 0;
 
-static int tcp_level = 0;
-
 /* global to store what chain the debug unit is currently connected to 
 (not the JTAG TAP, but the onchip debug module has selected) */
 int gdb_chain = -1;
@@ -356,10 +354,6 @@
 
 /* Forward declarations of static functions */
 static char *printTime(void);
-static int gdb_read(void*, int);
-static int gdb_write(void*, int);
-static void ProtocolClean(int, int32_t);
-static void GDBRequest(void);
 static void rsp_interrupt();
 static char rsp_peek();
 static struct rsp_buf *get_packet (void);
@@ -367,7 +361,7 @@
 static void set_npc (uint32_t  addr);
 static uint32_t get_npc();
 static void rsp_check_for_exception();
-static int check_for_exception_vector(uint32_t ppc);
+/*static int check_for_exception_vector(uint32_t ppc);*/
 static void rsp_exception (uint32_t  except);
 static int get_rsp_char (void);
 static int hex (int  c);
@@ -402,7 +396,7 @@
 static void get_debug_registers(void);
 static void put_debug_registers(void);
 static int find_free_dcrdvr_pair(void);
-static int count_free_dcrdvr_pairs(void);
+/*static int count_free_dcrdvr_pairs(void);*/
 static int find_matching_dcrdvr_pair(uint32_t addr, uint32_t cc);
 static void insert_hw_watchpoint(int wp_num, uint32_t address, uint32_t cc);
 static void remove_hw_watchpoint(int wp_num);
@@ -419,11 +413,11 @@
 static void	reg2hex (uint32_t  val, char *p_buf);
 static void swap_buf(char* p_buf, int len);
 static void set_stall_state (int state);
-static void reset_or1k (void);
+/*static void reset_or1k (void);*/
 static void gdb_ensure_or1k_stalled();
 static int gdb_set_chain(int chain);
 static int gdb_write_byte(uint32_t adr, uint8_t data);
-static int gdb_write_short(uint32_t adr, uint16_t data);
+/*static int gdb_write_short(uint32_t adr, uint16_t data);*/
 static int gdb_write_reg(uint32_t adr, uint32_t data);
 static int gdb_read_byte(uint32_t adr, uint8_t *data);
 static int gdb_read_reg(uint32_t adr, uint32_t *data);
@@ -635,7 +629,7 @@
   
   return;  
 }
-
+#if 0
 /*---------------------------------------------------------------------------*/
 /*!Check if PPC is in an exception vector that halts program flow
 
@@ -665,7 +659,7 @@
     }
   return 1; 
 }
-
+#endif
 /*---------------------------------------------------------------------------*/
 /*!Note an exception for future processing
 
@@ -1110,7 +1104,7 @@
 {
   unsigned char  data[GDB_BUF_MAX * 2];
   int   len;
-  int   ch;				/* Ack char */
+  unsigned char ch;				/* Ack char */
 
   /* Construct $<packet info>#<checksum>. Repeat until the GDB client
      acknowledges satisfactory receipt. */
@@ -1130,7 +1124,7 @@
     /* Body of the packet */
     for (count = 0; count < p_buf->len; count++)
 		{
-		  unsigned char  ch = p_buf->data[count];
+		  ch = p_buf->data[count];
 
 		  /* Check for escaped chars */
 		  if (('$' == ch) || ('#' == ch) || ('*' == ch) || ('}' == ch))
@@ -2027,8 +2021,6 @@
 rsp_continue_generic (uint32_t  addr,
 		      uint32_t  except)
 {
-  uint32_t		temp_uint32;
-  
   /* Set the address as the value of the next program counter */
   set_npc (addr);
   
@@ -2209,18 +2201,11 @@
   unsigned int    addr;			/* Where to read the memory */
   int             len;			/* Number of bytes to read */
   int             off;			/* Offset into the memory */
-  uint32_t		temp_uint32 = 0;
   char 						*rec_buf, *rec_buf_ptr;
   int bytes_per_word = 4; /* Current OR implementation is 4-byte words */
   int i;
   int len_cpy;
-  /* Couple of temps we might need when doing aligning/leftover accesses */
-  uint32_t tmp_word;
-  uint8_t tmp_byte;
-  char *tmp_word_ptr = (char*) &tmp_word;
-  
 
-
   if (2 != sscanf (p_buf->data, "m%x,%x:", &addr, &len))
   {
     fprintf (stderr, "Warning: Failed to recognize RSP read memory "
@@ -2986,7 +2971,6 @@
   }
   else if (0 == strncmp ("writespr ", cmd, strlen ("writespr")))
     {
-      unsigned int       regno;
       uint32_t  val;
       
       /* Parse and return error if we fail */
@@ -3179,8 +3163,6 @@
 rsp_step_generic (uint32_t  addr,
 		  uint32_t  except)
 {
-  uint32_t		temp_uint32;
-  
   /* Set the address as the value of the next program counter */
   
   set_npc (addr);
@@ -3496,13 +3478,11 @@
   /* TODO: Block CPU registers write functionality */
   if (DEBUG_GDB) printf("gdb - put_debug_registers()\n");
   int i;
-  uint32_t *dbg_regs_ptr = (uint32_t *) &or1k_dbg_group_regs_cache;
 
   if (DEBUG_GDB)
     {
       printf("gdb - put_debug_registers() - registers:\n\t");
       uint32_t * regs_ptr = (uint32_t*) &or1k_dbg_group_regs_cache;
-      int i; 
       for(i=0;i<(sizeof(or1k_dbg_group_regs_cache)/4);i++)     
 	{ if (i%4==0)printf("\n\t");
 	  if (i<8)
@@ -3563,6 +3543,7 @@
   // If the loop finished, no appropriate matchpoints
   return -1;
 } /* find_matching_dcrdvr_pair() */
+#if 0
  /*---------------------------------------------------------------------------*/
 /*!Count number of free DCR/DVR pairs
 
@@ -3571,18 +3552,18 @@
 static int
 count_free_dcrdvr_pairs(void)
 {
-  int i, free=0;
+  int i, _free=0;
   for (i=0;i<OR1K_MAX_MATCHPOINTS; i++)
     {
       if ((or1k_dbg_group_regs_cache.dcr[i].cc == OR1K_CC_MASKED) // If compare condition is masked, it's not used
 	  && or1k_dbg_group_regs_cache.dcr[i].dp ) // and the debug point is present
-	free++;
+	_free++;
     }
   
   
-  return free;
+  return _free;
 } /* count_free_dcrdvr_pairs() */
-
+#endif
 /*---------------------------------------------------------------------------*/
 /*!Find a free hardware breakpoint register, DCR/DVR pair
 
@@ -3644,8 +3625,6 @@
   
   // Mark the debug reg cache as dirty
   dbg_regs_cache_dirty = 1;
-  return;
-  
 } /* remove_hw_watchpoint() */
 
 /*---------------------------------------------------------------------------*/
@@ -3660,7 +3639,6 @@
   or1k_dbg_group_regs_cache.dmr2 |= (uint32_t) (1 << (SPR_DMR2_WGB_OFF + wp_num));
   // Mark the debug reg cache as dirty
   dbg_regs_cache_dirty = 1;
-  return;
 } /* enable_hw_breakpoint() */
 
 /*---------------------------------------------------------------------------*/
@@ -3675,7 +3653,6 @@
   or1k_dbg_group_regs_cache.dmr2 &= (uint32_t) ~(1 << (SPR_DMR2_WGB_OFF + wp_num));
   // Mark the debug reg cache as dirty
   dbg_regs_cache_dirty = 1;
-  return;
 } /* disable_hw_breakpoint() */
       
 /*---------------------------------------------------------------------------*/
@@ -4028,7 +4005,7 @@
   default:            return JTAG_PROXY_INVALID_CHAIN;
   }
 }
-
+#if 0
  int gdb_write_short(uint32_t adr, uint16_t data) {
    if (DEBUG_CMDS) printf("wshort %d\n", gdb_chain); fflush (stdout);
    switch (gdb_chain) {
@@ -4037,7 +4014,7 @@
   default:            return JTAG_PROXY_INVALID_CHAIN;
   }
 }
-
+#endif
 int gdb_write_reg(uint32_t adr, uint32_t data) {
   if (DEBUG_CMDS) printf("wreg %d\n", gdb_chain); fflush (stdout);
   switch (gdb_chain) { /* remap registers, to be compatible with jp1 */
@@ -4088,10 +4065,10 @@
 /*****************************************************************************
 * Close the connection to the client if it is open
 ******************************************************************************/
-static void client_close (char err)
+static void client_close (char error)
 {
   if(gdb_fd) {
-    perror("gdb socket - " + err);
+    perror("gdb socket - " + error);
     close(gdb_fd);
     gdb_fd = 0;
   }
@@ -4153,7 +4130,7 @@
 
 }	/* set_stall_state () */
 
-
+#if 0
 /*---------------------------------------------------------------------------*/
 /*!Set the reset bit of the processor's control reg in debug interface
  */
@@ -4167,7 +4144,7 @@
   if(err > 0 && DEBUG_GDB)printf("Error %d in reset_or1k()\n", err);
 
 }	/* reset_or1k () */
-
+#endif
 /*---------------------------------------------------------------------------*/
 /*!Close down the connection with GDB in the event of a kill signal
 
