Main Page | Modules | File List | Globals | Examples

Register and Memory access

Register and memory space read/write. More...

Defines

#define LDST_32   0
 Word size 32 bits.
#define LDST_16   1
 Word size 16 bits.
#define LDST_8   2
 Word size 8 bits.

Functions

int get_memory (CPU cpu, ADDR addr, unsigned long count, unsigned char *buf)
 Read from CPU side memory.
int set_memory (CPU cpu, ADDR addr, unsigned long count, const unsigned char *buf)
 Write to CPU side memory.
int get_memory_word (CPU cpu, ADDR addr, unsigned long *word, int sizecode)
 Read MMR registers.
int set_memory_word (CPU cpu, ADDR addr, unsigned long word, int sizecode)
 Write to MMR registers.
BFIN_REGISTER get_cpuregister (CPU cpu, int regno)
 Get CPU register value.
int set_cpuregister (CPU cpu, int regno, BFIN_REGISTER value)
 Set CPU core register value.
int save_registers (CPU cpu, BFIN_REGISTER *buf, int *regs)
 Save CPU registers to buffer.
int restore_registers (CPU cpu, BFIN_REGISTER *buf, int *regs)
 Restore CPU registers from buffer.
int save_dagregisters (CPU cpu, BFIN_REGISTER *buf)
 Save DAG registers.
int save_aluregisters (CPU cpu, BFIN_REGISTER *buf)
 Save ALU registers.
int get_idcode (CPU cpu, unsigned long *code)
 Get value of IDCODE register.
BFIN_REGISTER get_dbgstat (CPU cpu)
 Get value of DBGSTAT register.
int cpu_reset (CPU cpu, int mode)
 Reset CPU This function resets the CPU according to the mode value:.

Detailed Description

These functions only work if the Blackfin core is in emulation mode. See Emulation for details.

Function Documentation

int cpu_reset CPU  cpu,
int  mode
 

Parameters:
mode 1: reset Core, 2: reset System, 3: both. A value of 0 causes no action.
Examples:
memtest.c.

BFIN_REGISTER get_cpuregister CPU  cpu,
int  regno
 

This function retrieves the content of a core register via JTAG.

Parameters:
regno A register token from enum bfin_registers {..} (see bfin-registers.h)
Examples:
register.c.

int get_idcode CPU  cpu,
unsigned long *  code
 

Parameters:
code,: Pointer to variable where IDCODE is stored
Returns:
< 0: error

int get_memory CPU  cpu,
ADDR  addr,
unsigned long  count,
unsigned char *  buf
 

Note that access speed is faster when

  • addr and
  • size are a multiple of four, or two.
Parameters:
addr Address in Blackfin memory space to read from
count Block size in bytes
buf Pointer to buffer to store data in
Returns:
0: no error, < 0: error
Examples:
memtest.c.

int get_memory_word CPU  cpu,
ADDR  addr,
unsigned long *  word,
int  sizecode
 

Normally, the MMR range starts at 0xffc00000 for the supported Blackfin architectures. Use this function when accessing a memory mapped register.

Parameters:
addr The MMR register address
word Pointer to the word where data is to be stored
sizecode Either LDST_16 or LDST_32, depending on register size

int restore_registers CPU  cpu,
BFIN_REGISTER *  buf,
int *  regs
 

See save_registers()

int save_aluregisters CPU  cpu,
BFIN_REGISTER *  buf
 

See save_dagregisters() for behaviour.

Parameters:
buf Pointer to BFIN_REGISTER array[4]; The layout of the buffer content corresponds to the register map in bfin-registers.h, starting from REG_A0x

int save_dagregisters CPU  cpu,
BFIN_REGISTER *  buf
 

This call is used to save the DAG registers into a register context buffer. r0 is modified within this call!

Make sure you save r0, or encapsulate this call in between save_registers() and restore_registers() including REG_R0 in the register list.

Parameters:
buf Pointer to BFIN_REGISTER array[16]; The layout of the buffer content corresponds to the register map in bfin-registers.h, starting from REG_I0

int save_registers CPU  cpu,
BFIN_REGISTER *  buf,
int *  regs
 

An action manipulating the CPU registers should always be encapsulated by a save_registers() and restore_registers() call.

Parameters:
buf Buffer to save registers to. This must have the size of the number of registers in the register list below. If all registers are to be restored
regs List of registers to save. Must be terminated with -1. Do not use this call to access the the following registers: REG_I0 <= register <= REG_L3, REG_A0x, REG_A0w, REG_A1x, REG_A1w, REG_EMUDAT
Examples:
register.c.

int set_cpuregister CPU  cpu,
int  regno,
BFIN_REGISTER  value
 

Parameters:
regno A register token from enum bfin_registers {..} (see bfin-registers.h)
value The register value

int set_memory CPU  cpu,
ADDR  addr,
unsigned long  count,
const unsigned char *  buf
 

Note that access speed is faster when

  • addr and
  • size are a multiple of four, or two.
Parameters:
addr Address in Blackfin memory space to write to
count Block size in bytes
buf Pointer to buffer containing data
Returns:
0: no error, < 0: error
Examples:
memtest.c.

int set_memory_word CPU  cpu,
ADDR  addr,
unsigned long  word,
int  sizecode
 

See also get_memory_word() about the valid memory range.

Parameters:
addr The MMR register address to write to
word Data to write
sizecode Either LDST_16 or LDST_32, depending on register size
Examples:
memtest.c.


Generated on Thu Sep 1 15:02:53 2005 for bfemu - Blackfin emulation library by  doxygen 1.4.3-20050530