OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-6.8/] [gdb/] [or1k-jtag.h] - Diff between revs 827 and 840

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 827 Rev 840
/* Remote debugging interface for OpenRISC 1000 JTAG debugging protocol.
/* Remote debugging interface for OpenRISC 1000 JTAG debugging protocol.
 
 
   Copyright (C) 2001 Chris Ziomkowski, chris@asics.ws
   Copyright (C) 2001 Chris Ziomkowski, chris@asics.ws
   Copyright 2008 Embecosm Limited
   Copyright 2008 Embecosm Limited
 
 
   Areas noted by (CZ) were modified by Chris Ziomkowski <chris@asics.ws>
   Areas noted by (CZ) were modified by Chris Ziomkowski <chris@asics.ws>
   Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
   Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
 
 
   This file is part of GDB.
   This file is part of GDB.
 
 
   This program is free software; you can redistribute it and/or modify it
   This program is free software; you can redistribute it and/or modify it
   under the terms of the GNU General Public License as published by the Free
   under the terms of the GNU General Public License as published by the Free
   Software Foundation; either version 3 of the License, or (at your option)
   Software Foundation; either version 3 of the License, or (at your option)
   any later version.
   any later version.
 
 
   This program is distributed in the hope that it will be useful, but WITHOUT
   This program is distributed in the hope that it will be useful, but WITHOUT
   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
   more details.
   more details.
 
 
   You should have received a copy of the GNU General Public License along
   You should have received a copy of the GNU General Public License along
   with this program.  If not, see <http://www.gnu.org/licenses/>.
   with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
*/
 
 
/*!---------------------------------------------------------------------------
/*!---------------------------------------------------------------------------
   Updated for GDB 6.8 by Jeremy Bennett. All code converted to ANSI C style
   Updated for GDB 6.8 by Jeremy Bennett. All code converted to ANSI C style
   and in general to GDB format. All global OpenRISC specific functions and
   and in general to GDB format. All global OpenRISC specific functions and
   variables should now have a prefix of or1k_ or OR1K_.
   variables should now have a prefix of or1k_ or OR1K_.
 
 
   JTAG connects to or1k target ops. See or1k-tdep.c. This header is also used
   JTAG connects to or1k target ops. See or1k-tdep.c. This header is also used
   by Or1ksim, the OpenRISC 1000 architectural simulator.
   by Or1ksim, the OpenRISC 1000 architectural simulator.
   --------------------------------------------------------------------------*/
   --------------------------------------------------------------------------*/
 
 
#ifndef OR1K_JTAG__H
#ifndef OR1K_JTAG__H
#define OR1K_JTAG__H
#define OR1K_JTAG__H
 
 
#include <sys/types.h>
#include <sys/types.h>
#include <inttypes.h>
#include <inttypes.h>
 
 
/*! JTAG instruction size. See JTAG documentation about these.  */
/*! JTAG instruction size. See JTAG documentation about these.  */
#define OR1K_JI_SIZE (4)
#define OR1K_JI_SIZE (4)
 
 
/*! JTAG instructions. See JTAG documentation about these.  */
/*! JTAG instructions. See JTAG documentation about these.  */
enum or1k_jtag_instr {
enum or1k_jtag_instr {
  OR1K_JI_CHAIN_SELECT = 3,
  OR1K_JI_CHAIN_SELECT = 3,
  OR1K_JI_DEBUG        = 8
  OR1K_JI_DEBUG        = 8
};
};
 
 
/*! Scan chain size in bits.  */
/*! Scan chain size in bits.  */
#define OR1K_SC_SIZE (4)
#define OR1K_SC_SIZE (4)
 
 
/*! All JTAG chains.  */
/*! All JTAG chains.  */
enum or1k_jtag_chains {
enum or1k_jtag_chains {
  OR1K_SC_UNDEF      = -1,      /* Scan chain not defined */
  OR1K_SC_UNDEF      = -1,      /* Scan chain not defined */
  OR1K_SC_RISC_DEBUG =  1,      /* 1 RISC Debug Interface chain (for SPRs) */
  OR1K_SC_RISC_DEBUG =  1,      /* 1 RISC Debug Interface chain (for SPRs) */
  OR1K_SC_REGISTER   =  4,      /* 4 JTAG Register Chain */
  OR1K_SC_REGISTER   =  4,      /* 4 JTAG Register Chain */
  OR1K_SC_WISHBONE   =  5,      /* 5 Wisbone Chain (for memory access) */
  OR1K_SC_WISHBONE   =  5,      /* 5 Wisbone Chain (for memory access) */
};
};
 
 
/*! Version of the debug interface. This affects the address on the control
/*! Version of the debug interface. This affects the address on the control
    (SC_REGISTER) scan chain. */
    (SC_REGISTER) scan chain. */
enum or1k_dbg_if_version_enum {
enum or1k_dbg_if_version_enum {
  OR1K_DBG_IF_ORPSOC,                   /* Version with ORPSoC */
  OR1K_DBG_IF_ORPSOC,                   /* Version with ORPSoC */
  OR1K_DBG_IF_MOHOR                     /* Igor Mohor's debug interface */
  OR1K_DBG_IF_MOHOR                     /* Igor Mohor's debug interface */
};
};
 
 
/*! JTAG registers (for use with ORK1_SC_REGISTER scan chain). There are two
/*! JTAG registers (for use with ORK1_SC_REGISTER scan chain). There are two
   flavours of this, depending which version of the debug interface you are
   flavours of this, depending which version of the debug interface you are
   using. */
   using. */
#define OR1K_JTAG_RISCOP  (OR1K_DBG_IF_ORPSOC == or1k_dbg_if_version ? 0x04 : \
#define OR1K_JTAG_RISCOP  (OR1K_DBG_IF_ORPSOC == or1k_dbg_if_version ? 0x04 : \
                                                                       0x00 )
                                                                       0x00 )
 
 
/* JTAG register fields */
/* JTAG register fields */
 
 
#define OR1K_JTAG_RISCOP_STALL  0x00000001
#define OR1K_JTAG_RISCOP_STALL  0x00000001
#define OR1K_JTAG_RISCOP_RESET  0x00000002
#define OR1K_JTAG_RISCOP_RESET  0x00000002
 
 
/*! The OR1K JTAG proxy protocol commands. */
/*! The OR1K JTAG proxy protocol commands. */
enum or1k_jtag_proxy_protocol_commands {
enum or1k_jtag_proxy_protocol_commands {
  OR1K_JTAG_COMMAND_READ        = 1,
  OR1K_JTAG_COMMAND_READ        = 1,
  OR1K_JTAG_COMMAND_WRITE       = 2,
  OR1K_JTAG_COMMAND_WRITE       = 2,
  OR1K_JTAG_COMMAND_READ_BLOCK  = 3,
  OR1K_JTAG_COMMAND_READ_BLOCK  = 3,
  OR1K_JTAG_COMMAND_WRITE_BLOCK = 4,
  OR1K_JTAG_COMMAND_WRITE_BLOCK = 4,
  OR1K_JTAG_COMMAND_CHAIN       = 5,
  OR1K_JTAG_COMMAND_CHAIN       = 5,
};
};
 
 
/*! Maximum size of write block sent in one go */
/*! Maximum size of write block sent in one go */
#define  OR1K_MAX_JTAG_WRITE  1024
#define  OR1K_MAX_JTAG_WRITE  1024
 
 
/* Each transmit structure must begin with an integer which specifies the type
/* Each transmit structure must begin with an integer which specifies the type
 * of command. Information after this is variable. Make sure to have all
 * of command. Information after this is variable. Make sure to have all
 * information aligned properly. If we stick with 32 bit integers, it should
 * information aligned properly. If we stick with 32 bit integers, it should
 * be portable onto every platform. These structures will be transmitted
 * be portable onto every platform. These structures will be transmitted
 * across the network in network byte order.
 * across the network in network byte order.
*/
*/
 
 
struct jtr_read_message {
struct jtr_read_message {
  uint32_t  command;
  uint32_t  command;
  uint32_t  length;
  uint32_t  length;
  uint32_t  address;
  uint32_t  address;
};
};
 
 
struct jtr_write_message {
struct jtr_write_message {
  uint32_t  command;
  uint32_t  command;
  uint32_t  length;
  uint32_t  length;
  uint32_t  address;
  uint32_t  address;
  uint32_t  data_h;
  uint32_t  data_h;
  uint32_t  data_l;
  uint32_t  data_l;
};
};
 
 
struct jtr_read_block_message {
struct jtr_read_block_message {
  uint32_t  command;
  uint32_t  command;
  uint32_t  length;
  uint32_t  length;
  uint32_t  address;
  uint32_t  address;
  int32_t   num_regs;
  int32_t   num_regs;
};
};
 
 
struct jtr_write_block_message {
struct jtr_write_block_message {
  uint32_t  command;
  uint32_t  command;
  uint32_t  length;
  uint32_t  length;
  uint32_t  address;
  uint32_t  address;
  int32_t   num_regs;
  int32_t   num_regs;
  uint32_t  data[1];
  uint32_t  data[1];
};
};
 
 
struct jtr_chain_message {
struct jtr_chain_message {
  uint32_t  command;
  uint32_t  command;
  uint32_t  length;
  uint32_t  length;
  uint32_t  chain;
  uint32_t  chain;
};
};
 
 
/* The responses are messages specific, however convention states the first
/* The responses are messages specific, however convention states the first
 * word should be an error code. Again, sticking with 32 bit integers should
 * word should be an error code. Again, sticking with 32 bit integers should
 * provide maximum portability. */
 * provide maximum portability. */
 
 
struct jtr_failure_response {
struct jtr_failure_response {
  int32_t  status;
  int32_t  status;
};
};
 
 
struct jtr_read_response {
struct jtr_read_response {
  int32_t   status;
  int32_t   status;
  uint32_t  data_h;
  uint32_t  data_h;
  uint32_t  data_l;
  uint32_t  data_l;
};
};
 
 
struct jtr_write_response {
struct jtr_write_response {
  int32_t  status;
  int32_t  status;
};
};
 
 
struct jtr_read_block_response {
struct jtr_read_block_response {
  int32_t   status;
  int32_t   status;
  int32_t   num_regs;
  int32_t   num_regs;
};
};
 
 
struct jtr_write_block_response {
struct jtr_write_block_response {
  int32_t  status;
  int32_t  status;
};
};
 
 
struct jtr_chain_response {
struct jtr_chain_response {
  int32_t  status;
  int32_t  status;
};
};
 
 
 
 
/*! Error codes for the OpenRISC 1000 JTAG debugging protocol */
/*! Error codes for the OpenRISC 1000 JTAG debugging protocol */
enum or1k_jtag_errors  /* modified <chris@asics.ws> CZ 24/05/01 */
enum or1k_jtag_errors  /* modified <chris@asics.ws> CZ 24/05/01 */
{
{
  /* Codes > 0 are for system errors */
  /* Codes > 0 are for system errors */
 
 
  OR1K_JTAG_ERR_NONE = 0,
  OR1K_JTAG_ERR_NONE = 0,
  OR1K_JTAG_ERR_CRC = -1,
  OR1K_JTAG_ERR_CRC = -1,
  OR1K_JTAG_ERR_MEM = -2,
  OR1K_JTAG_ERR_MEM = -2,
  OR1K_JTAG_ERR_INVALID_COMMAND = -3,
  OR1K_JTAG_ERR_INVALID_COMMAND = -3,
  OR1K_JTAG_ERR_SERVER_TERMINATED = -4,
  OR1K_JTAG_ERR_SERVER_TERMINATED = -4,
  OR1K_JTAG_ERR_NO_CONNECTION = -5,
  OR1K_JTAG_ERR_NO_CONNECTION = -5,
  OR1K_JTAG_ERR_PROTOCOL_ERROR = -6,
  OR1K_JTAG_ERR_PROTOCOL_ERROR = -6,
  OR1K_JTAG_ERR_COMMAND_NOT_IMPLEMENTED = -7,
  OR1K_JTAG_ERR_COMMAND_NOT_IMPLEMENTED = -7,
  OR1K_JTAG_ERR_INVALID_CHAIN = -8,
  OR1K_JTAG_ERR_INVALID_CHAIN = -8,
  OR1K_JTAG_ERR_INVALID_ADDRESS = -9,
  OR1K_JTAG_ERR_INVALID_ADDRESS = -9,
  OR1K_JTAG_ERR_ACCESS_EXCEPTION = -10, /* Write to ROM */
  OR1K_JTAG_ERR_ACCESS_EXCEPTION = -10, /* Write to ROM */
  OR1K_JTAG_ERR_INVALID_LENGTH = -11,
  OR1K_JTAG_ERR_INVALID_LENGTH = -11,
  OR1K_JTAG_ERR_OUT_OF_MEMORY = -12,
  OR1K_JTAG_ERR_OUT_OF_MEMORY = -12,
};
};
 
 
/* Global variable identifying the debug interface version */
/* Global variable identifying the debug interface version */
extern enum or1k_dbg_if_version_enum  or1k_dbg_if_version;
extern enum or1k_dbg_if_version_enum  or1k_dbg_if_version;
 
 
/* Global OR1K JTAG functions */
/* Global OR1K JTAG functions */
extern void      or1k_jtag_init (char *args);
extern void      or1k_jtag_init (char *args);
extern void      or1k_jtag_close ();
extern void      or1k_jtag_close ();
extern ULONGEST  or1k_jtag_read_spr (unsigned int  sprnum);
extern ULONGEST  or1k_jtag_read_spr (unsigned int  sprnum);
extern void      or1k_jtag_write_spr (unsigned int  sprnum,
extern void      or1k_jtag_write_spr (unsigned int  sprnum,
                                      ULONGEST      data);
                                      ULONGEST      data);
extern int       or1k_jtag_read_mem (CORE_ADDR  addr,
extern int       or1k_jtag_read_mem (CORE_ADDR  addr,
                                     gdb_byte  *bdata,
                                     gdb_byte  *bdata,
                                     int        len);
                                     int        len);
extern int       or1k_jtag_write_mem (CORE_ADDR       addr,
extern int       or1k_jtag_write_mem (CORE_ADDR       addr,
                                      const gdb_byte *bdata,
                                      const gdb_byte *bdata,
                                      int             len);
                                      int             len);
extern void      or1k_jtag_stall ();
extern void      or1k_jtag_stall ();
extern void      or1k_jtag_unstall ();
extern void      or1k_jtag_unstall ();
extern void      or1k_jtag_wait (int  fast);
extern void      or1k_jtag_wait (int  fast);
 
 
 
 
#endif /* OR1K_JTAG__H */
#endif /* OR1K_JTAG__H */
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.