OpenOCD
rshim.c File Reference
Include dependency graph for rshim.c:

Go to the source code of this file.

Macros

#define APB_AP_IDR   0x44770002
 
#define RSH_CORESIGHT_CTL   0x0e00
 
#define RSH_CORESIGHT_CTL_ACTION_MASK   0x2ULL
 
#define RSH_CORESIGHT_CTL_ACTION_SHIFT   1
 
#define RSH_CORESIGHT_CTL_ADDR_MASK   0x7ffffffcULL
 
#define RSH_CORESIGHT_CTL_ADDR_SHIFT   2
 
#define RSH_CORESIGHT_CTL_DATA_MASK   0xffffffff00000000ULL
 
#define RSH_CORESIGHT_CTL_DATA_SHIFT   32
 
#define RSH_CORESIGHT_CTL_ERR_MASK   0x80000000ULL
 
#define RSH_CORESIGHT_CTL_ERR_SHIFT   31
 
#define RSH_CORESIGHT_CTL_GO_MASK   0x1ULL
 
#define RSH_CORESIGHT_CTL_GO_SHIFT   0
 
#define RSH_CS_GET_FIELD(reg, field)
 
#define RSH_CS_ROM_BASE   0x80000000
 
#define RSH_CS_SET_FIELD(reg, field, value)
 
#define RSH_CS_TILE_BASE   0x44000000
 
#define RSH_CS_TILE_SIZE   0x04000000
 
#define RSH_MMIO_CHANNEL_RSHIM   0x1
 
#define RSHIM_DEV_PATH_DEFAULT   "/dev/rshim0/rshim"
 

Functions

static void ap_addr_2_tile (int *tile, uint32_t *addr)
 
 COMMAND_HANDLER (rshim_dap_device_command)
 
static int coresight_read (uint32_t tile, uint32_t addr, uint32_t *value)
 
static int coresight_write (uint32_t tile, uint32_t addr, uint32_t wdata)
 
static int rshim_ap_q_abort (struct adiv5_dap *dap, uint8_t *ack)
 
static int rshim_ap_q_read (struct adiv5_ap *ap, unsigned int reg, uint32_t *data)
 
static int rshim_ap_q_write (struct adiv5_ap *ap, unsigned int reg, uint32_t data)
 
static int rshim_connect (struct adiv5_dap *dap)
 
static int rshim_dap_init (void)
 
static int rshim_dap_khz (int khz, int *jtag_speed)
 
static int rshim_dap_quit (void)
 
static int rshim_dap_reset (int req_trst, int req_srst)
 
static int rshim_dap_speed (int speed)
 
static int rshim_dap_speed_div (int speed, int *khz)
 
static int rshim_dev_read (int chan, int addr, uint64_t *value)
 
static int rshim_dev_write (int chan, int addr, uint64_t value)
 
static void rshim_disconnect (struct adiv5_dap *dap)
 
static int rshim_dp_q_read (struct adiv5_dap *dap, unsigned int reg, uint32_t *data)
 
static int rshim_dp_q_write (struct adiv5_dap *dap, unsigned int reg, uint32_t data)
 
static int rshim_dp_run (struct adiv5_dap *dap)
 

Variables

static uint32_t ap_bank
 
static uint32_t ap_csw
 
static uint32_t ap_drw
 
static uint32_t ap_sel
 
static uint32_t ap_tar
 
static uint32_t ap_tar_inc
 
static uint32_t dp_ctrl_stat
 
static uint32_t dp_id_code
 
struct adapter_driver rshim_dap_adapter_driver
 
static const struct command_registration rshim_dap_command_handlers []
 
static const struct dap_ops rshim_dap_ops
 
static int rshim_dap_retval = ERROR_OK
 
static const struct command_registration rshim_dap_subcommand_handlers []
 
static const char *const rshim_dap_transport [] = { "dapdirect_swd", NULL }
 
static char * rshim_dev_path
 
static int rshim_fd = -1
 
static int(* rshim_read )(int chan, int addr, uint64_t *value)
 
static int(* rshim_write )(int chan, int addr, uint64_t value)
 

Macro Definition Documentation

◆ APB_AP_IDR

#define APB_AP_IDR   0x44770002

Definition at line 36 of file rshim.c.

◆ RSH_CORESIGHT_CTL

#define RSH_CORESIGHT_CTL   0x0e00

Definition at line 39 of file rshim.c.

◆ RSH_CORESIGHT_CTL_ACTION_MASK

#define RSH_CORESIGHT_CTL_ACTION_MASK   0x2ULL

Definition at line 43 of file rshim.c.

◆ RSH_CORESIGHT_CTL_ACTION_SHIFT

#define RSH_CORESIGHT_CTL_ACTION_SHIFT   1

Definition at line 42 of file rshim.c.

◆ RSH_CORESIGHT_CTL_ADDR_MASK

#define RSH_CORESIGHT_CTL_ADDR_MASK   0x7ffffffcULL

Definition at line 45 of file rshim.c.

◆ RSH_CORESIGHT_CTL_ADDR_SHIFT

#define RSH_CORESIGHT_CTL_ADDR_SHIFT   2

Definition at line 44 of file rshim.c.

◆ RSH_CORESIGHT_CTL_DATA_MASK

#define RSH_CORESIGHT_CTL_DATA_MASK   0xffffffff00000000ULL

Definition at line 49 of file rshim.c.

◆ RSH_CORESIGHT_CTL_DATA_SHIFT

#define RSH_CORESIGHT_CTL_DATA_SHIFT   32

Definition at line 48 of file rshim.c.

◆ RSH_CORESIGHT_CTL_ERR_MASK

#define RSH_CORESIGHT_CTL_ERR_MASK   0x80000000ULL

Definition at line 47 of file rshim.c.

◆ RSH_CORESIGHT_CTL_ERR_SHIFT

#define RSH_CORESIGHT_CTL_ERR_SHIFT   31

Definition at line 46 of file rshim.c.

◆ RSH_CORESIGHT_CTL_GO_MASK

#define RSH_CORESIGHT_CTL_GO_MASK   0x1ULL

Definition at line 41 of file rshim.c.

◆ RSH_CORESIGHT_CTL_GO_SHIFT

#define RSH_CORESIGHT_CTL_GO_SHIFT   0

Definition at line 40 of file rshim.c.

◆ RSH_CS_GET_FIELD

#define RSH_CS_GET_FIELD (   reg,
  field 
)
Value:
(((uint64_t)(reg) & RSH_CORESIGHT_CTL_##field##_MASK) >> \
RSH_CORESIGHT_CTL_##field##_SHIFT)
Definition: register.h:111

Definition at line 52 of file rshim.c.

◆ RSH_CS_ROM_BASE

#define RSH_CS_ROM_BASE   0x80000000

Definition at line 27 of file rshim.c.

◆ RSH_CS_SET_FIELD

#define RSH_CS_SET_FIELD (   reg,
  field,
  value 
)
Value:
(reg) = (((reg) & ~RSH_CORESIGHT_CTL_##field##_MASK) | \
(((uint64_t)(value) << RSH_CORESIGHT_CTL_##field##_SHIFT) & \
RSH_CORESIGHT_CTL_##field##_MASK))

Definition at line 56 of file rshim.c.

◆ RSH_CS_TILE_BASE

#define RSH_CS_TILE_BASE   0x44000000

Definition at line 28 of file rshim.c.

◆ RSH_CS_TILE_SIZE

#define RSH_CS_TILE_SIZE   0x04000000

Definition at line 29 of file rshim.c.

◆ RSH_MMIO_CHANNEL_RSHIM

#define RSH_MMIO_CHANNEL_RSHIM   0x1

Definition at line 24 of file rshim.c.

◆ RSHIM_DEV_PATH_DEFAULT

#define RSHIM_DEV_PATH_DEFAULT   "/dev/rshim0/rshim"

Definition at line 95 of file rshim.c.

Function Documentation

◆ ap_addr_2_tile()

static void ap_addr_2_tile ( int *  tile,
uint32_t *  addr 
)
static

Definition at line 141 of file rshim.c.

References addr, RSH_CS_ROM_BASE, RSH_CS_TILE_BASE, and RSH_CS_TILE_SIZE.

Referenced by rshim_ap_q_read(), and rshim_ap_q_write().

◆ COMMAND_HANDLER()

COMMAND_HANDLER ( rshim_dap_device_command  )

Definition at line 435 of file rshim.c.

References CMD_ARGC, CMD_ARGV, ERROR_COMMAND_SYNTAX_ERROR, ERROR_OK, and rshim_dev_path.

◆ coresight_read()

static int coresight_read ( uint32_t  tile,
uint32_t  addr,
uint32_t *  value 
)
static

◆ coresight_write()

static int coresight_write ( uint32_t  tile,
uint32_t  addr,
uint32_t  wdata 
)
static

◆ rshim_ap_q_abort()

static int rshim_ap_q_abort ( struct adiv5_dap dap,
uint8_t *  ack 
)
static

Definition at line 391 of file rshim.c.

References ERROR_OK.

◆ rshim_ap_q_read()

◆ rshim_ap_q_write()

◆ rshim_connect()

static int rshim_connect ( struct adiv5_dap dap)
static

◆ rshim_dap_init()

static int rshim_dap_init ( void  )
static

Definition at line 467 of file rshim.c.

References ERROR_OK.

◆ rshim_dap_khz()

static int rshim_dap_khz ( int  khz,
int *  jtag_speed 
)
static

Definition at line 487 of file rshim.c.

References ERROR_OK.

◆ rshim_dap_quit()

static int rshim_dap_quit ( void  )
static

Definition at line 472 of file rshim.c.

References ERROR_OK.

◆ rshim_dap_reset()

static int rshim_dap_reset ( int  req_trst,
int  req_srst 
)
static

Definition at line 477 of file rshim.c.

References ERROR_OK.

◆ rshim_dap_speed()

static int rshim_dap_speed ( int  speed)
static

Definition at line 482 of file rshim.c.

References ERROR_OK.

◆ rshim_dap_speed_div()

static int rshim_dap_speed_div ( int  speed,
int *  khz 
)
static

Definition at line 493 of file rshim.c.

◆ rshim_dev_read()

static int rshim_dev_read ( int  chan,
int  addr,
uint64_t *  value 
)
static

Definition at line 98 of file rshim.c.

References addr, and rshim_fd.

Referenced by rshim_connect().

◆ rshim_dev_write()

static int rshim_dev_write ( int  chan,
int  addr,
uint64_t  value 
)
static

Definition at line 120 of file rshim.c.

References addr, and rshim_fd.

Referenced by rshim_connect().

◆ rshim_disconnect()

static void rshim_disconnect ( struct adiv5_dap dap)
static

Definition at line 427 of file rshim.c.

References rshim_fd.

◆ rshim_dp_q_read()

static int rshim_dp_q_read ( struct adiv5_dap dap,
unsigned int  reg,
uint32_t *  data 
)
static

Definition at line 227 of file rshim.c.

References CDBGPWRUPACK, CSYSPWRUPACK, DP_CTRL_STAT, DP_DPIDR, dp_id_code, and ERROR_OK.

◆ rshim_dp_q_write()

static int rshim_dp_q_write ( struct adiv5_dap dap,
unsigned int  reg,
uint32_t  data 
)
static

◆ rshim_dp_run()

static int rshim_dp_run ( struct adiv5_dap dap)
static

Definition at line 396 of file rshim.c.

References ERROR_OK, and rshim_dap_retval.

Variable Documentation

◆ ap_bank

uint32_t ap_bank
static

Definition at line 77 of file rshim.c.

Referenced by rshim_ap_q_write(), and rshim_dp_q_write().

◆ ap_csw

uint32_t ap_csw
static

Definition at line 78 of file rshim.c.

Referenced by rshim_ap_q_read(), and rshim_ap_q_write().

◆ ap_drw

uint32_t ap_drw
static

Definition at line 79 of file rshim.c.

Referenced by rshim_ap_q_write().

◆ ap_sel

uint32_t ap_sel
static

Definition at line 77 of file rshim.c.

Referenced by rshim_dp_q_write().

◆ ap_tar

uint32_t ap_tar
static

Definition at line 80 of file rshim.c.

Referenced by rshim_ap_q_read(), and rshim_ap_q_write().

◆ ap_tar_inc

uint32_t ap_tar_inc
static

Definition at line 80 of file rshim.c.

Referenced by rshim_ap_q_read(), and rshim_ap_q_write().

◆ dp_ctrl_stat

uint32_t dp_ctrl_stat
static

Definition at line 75 of file rshim.c.

Referenced by rshim_dp_q_write().

◆ dp_id_code

uint32_t dp_id_code
static

Definition at line 76 of file rshim.c.

Referenced by rshim_dp_q_read().

◆ rshim_dap_adapter_driver

struct adapter_driver rshim_dap_adapter_driver
Initial value:
= {
.name = "rshim",
.transports = rshim_dap_transport,
.init = rshim_dap_init,
.quit = rshim_dap_quit,
.reset = rshim_dap_reset,
.speed = rshim_dap_speed,
.khz = rshim_dap_khz,
.speed_div = rshim_dap_speed_div,
.dap_swd_ops = &rshim_dap_ops,
}
static int rshim_dap_reset(int req_trst, int req_srst)
Definition: rshim.c:477
static int rshim_dap_khz(int khz, int *jtag_speed)
Definition: rshim.c:487
static int rshim_dap_speed(int speed)
Definition: rshim.c:482
static int rshim_dap_speed_div(int speed, int *khz)
Definition: rshim.c:493
static const struct dap_ops rshim_dap_ops
Definition: rshim.c:500
static const struct command_registration rshim_dap_command_handlers[]
Definition: rshim.c:456
static int rshim_dap_init(void)
Definition: rshim.c:467
static int rshim_dap_quit(void)
Definition: rshim.c:472
static const char *const rshim_dap_transport[]
Definition: rshim.c:511

Definition at line 511 of file rshim.c.

◆ rshim_dap_command_handlers

const struct command_registration rshim_dap_command_handlers[]
static
Initial value:
= {
{
.name = "rshim",
.mode = COMMAND_ANY,
.help = "perform rshim management",
.usage = "",
},
}
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
Definition: command.h:253
@ COMMAND_ANY
Definition: command.h:42
static const struct command_registration rshim_dap_subcommand_handlers[]
Definition: rshim.c:445
const char * usage
a string listing the options and arguments, required or optional
Definition: command.h:241

Definition at line 435 of file rshim.c.

◆ rshim_dap_ops

const struct dap_ops rshim_dap_ops
static
Initial value:
= {
.connect = rshim_connect,
.queue_dp_read = rshim_dp_q_read,
.queue_dp_write = rshim_dp_q_write,
.queue_ap_read = rshim_ap_q_read,
.queue_ap_write = rshim_ap_q_write,
.queue_ap_abort = rshim_ap_q_abort,
.run = rshim_dp_run,
}
static int rshim_ap_q_write(struct adiv5_ap *ap, unsigned int reg, uint32_t data)
Definition: rshim.c:332
static int rshim_ap_q_read(struct adiv5_ap *ap, unsigned int reg, uint32_t *data)
Definition: rshim.c:268
static int rshim_connect(struct adiv5_dap *dap)
Definition: rshim.c:406
static int rshim_dp_q_read(struct adiv5_dap *dap, unsigned int reg, uint32_t *data)
Definition: rshim.c:227
static int rshim_dp_q_write(struct adiv5_dap *dap, unsigned int reg, uint32_t data)
Definition: rshim.c:249
static int rshim_ap_q_abort(struct adiv5_dap *dap, uint8_t *ack)
Definition: rshim.c:391
static int rshim_dp_run(struct adiv5_dap *dap)
Definition: rshim.c:396
static void rshim_disconnect(struct adiv5_dap *dap)
Definition: rshim.c:427

Definition at line 493 of file rshim.c.

◆ rshim_dap_retval

int rshim_dap_retval = ERROR_OK
static

Definition at line 92 of file rshim.c.

Referenced by rshim_ap_q_read(), rshim_ap_q_write(), and rshim_dp_run().

◆ rshim_dap_subcommand_handlers

const struct command_registration rshim_dap_subcommand_handlers[]
static
Initial value:
= {
{
.name = "device",
.handler = rshim_dap_device_command,
.mode = COMMAND_CONFIG,
.help = "set the rshim device",
.usage = "</dev/rshim<N>/rshim>",
},
}
@ COMMAND_CONFIG
Definition: command.h:41

Definition at line 435 of file rshim.c.

◆ rshim_dap_transport

const char* const rshim_dap_transport[] = { "dapdirect_swd", NULL }
static

Definition at line 511 of file rshim.c.

◆ rshim_dev_path

char* rshim_dev_path
static

Definition at line 96 of file rshim.c.

Referenced by COMMAND_HANDLER(), and rshim_connect().

◆ rshim_fd

int rshim_fd = -1
static

Definition at line 89 of file rshim.c.

Referenced by rshim_connect(), rshim_dev_read(), rshim_dev_write(), and rshim_disconnect().

◆ rshim_read

int(* rshim_read) (int chan, int addr, uint64_t *value) ( int  chan,
int  addr,
uint64_t *  value 
)
static

Definition at line 83 of file rshim.c.

Referenced by coresight_read(), coresight_write(), and rshim_connect().

◆ rshim_write

int(* rshim_write) (int chan, int addr, uint64_t value) ( int  chan,
int  addr,
uint64_t  value 
)
static

Definition at line 84 of file rshim.c.

Referenced by coresight_read(), coresight_write(), and rshim_connect().