OpenOCD
types.h File Reference
Include dependency graph for types.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define __bool_true_false_are_defined   1
 
#define __stringify(s)   #s
 
#define ARRAY_SIZE(x)   (sizeof(x) / sizeof(*(x)))
 Compute the number of elements of a variable length array. More...
 
#define container_of(ptr, type, member)
 Cast a member of a structure out to the containing structure. More...
 
#define DIV_ROUND_UP(m, n)   (((m) + (n) - 1) / (n))
 Rounds m up to the nearest multiple of n using division. More...
 
#define false   0
 
#define stringify(s)   __stringify(s)
 turns a macro argument into a string constant More...
 
#define TARGET_ADDR_FMT   "0x%8.8" TARGET_PRIxADDR
 
#define TARGET_ADDR_MAX   UINT64_MAX
 
#define TARGET_PRIdADDR   PRId64
 
#define TARGET_PRIoADDR   PRIo64
 
#define TARGET_PRIuADDR   PRIu64
 
#define TARGET_PRIxADDR   PRIx64
 
#define TARGET_PRIXADDR   PRIX64
 
#define true   1
 

Typedefs

typedef uint64_t target_addr_t
 

Functions

static uint16_t be_to_h_u16 (const uint8_t *buf)
 
static uint32_t be_to_h_u24 (const uint8_t *buf)
 
static uint32_t be_to_h_u32 (const uint8_t *buf)
 
static uint64_t be_to_h_u64 (const uint8_t *buf)
 
static void buf_bswap16 (uint8_t *dst, const uint8_t *src, size_t len)
 Byte-swap buffer 16-bit. More...
 
static void buf_bswap32 (uint8_t *dst, const uint8_t *src, size_t len)
 Byte-swap buffer 32-bit. More...
 
static void h_u16_to_be (uint8_t *buf, uint16_t val)
 
static void h_u16_to_le (uint8_t *buf, uint16_t val)
 
static void h_u24_to_be (uint8_t *buf, unsigned int val)
 
static void h_u24_to_le (uint8_t *buf, unsigned int val)
 
static void h_u32_to_be (uint8_t *buf, uint32_t val)
 
static void h_u32_to_le (uint8_t *buf, uint32_t val)
 
static void h_u64_to_be (uint8_t *buf, uint64_t val)
 
static void h_u64_to_le (uint8_t *buf, uint64_t val)
 
static uint16_t le_to_h_u16 (const uint8_t *buf)
 
static uint32_t le_to_h_u24 (const uint8_t *buf)
 
static uint32_t le_to_h_u32 (const uint8_t *buf)
 
static uint64_t le_to_h_u64 (const uint8_t *buf)
 
static int parity_u32 (uint32_t x)
 Calculate the (even) parity of a 32-bit datum. More...
 

Macro Definition Documentation

◆ __bool_true_false_are_defined

#define __bool_true_false_are_defined   1

Definition at line 33 of file types.h.

◆ __stringify

#define __stringify (   s)    #s

Definition at line 47 of file types.h.

◆ ARRAY_SIZE

#define ARRAY_SIZE (   x)    (sizeof(x) / sizeof(*(x)))

Compute the number of elements of a variable length array.

const char *strs[] = { "a", "b", "c" }; unsigned num_strs = ARRAY_SIZE(strs);

Definition at line 57 of file types.h.

◆ container_of

#define container_of (   ptr,
  type,
  member 
)
Value:
({ \
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (void *) ( (char *)__mptr - offsetof(type,member) ) );})
uint8_t type
Definition: esp_usb_jtag.c:0

Cast a member of a structure out to the containing structure.

Parameters
ptrThe pointer to the member.
typeThe type of the container struct this is embedded in.
memberThe name of the member within the struct.

This is a mechanism which is used throughout the Linux kernel.

Definition at line 68 of file types.h.

◆ DIV_ROUND_UP

#define DIV_ROUND_UP (   m,
 
)    (((m) + (n) - 1) / (n))

Rounds m up to the nearest multiple of n using division.

Parameters
mThe value to round up to n.
nRound m up to a multiple of this number.
Returns
The rounded integer value.

Definition at line 79 of file types.h.

◆ false

#define false   0

Definition at line 38 of file types.h.

◆ stringify

#define stringify (   s)    __stringify(s)

turns a macro argument into a string constant

Definition at line 46 of file types.h.

◆ TARGET_ADDR_FMT

#define TARGET_ADDR_FMT   "0x%8.8" TARGET_PRIxADDR

Definition at line 342 of file types.h.

◆ TARGET_ADDR_MAX

#define TARGET_ADDR_MAX   UINT64_MAX

Definition at line 336 of file types.h.

◆ TARGET_PRIdADDR

#define TARGET_PRIdADDR   PRId64

Definition at line 337 of file types.h.

◆ TARGET_PRIoADDR

#define TARGET_PRIoADDR   PRIo64

Definition at line 339 of file types.h.

◆ TARGET_PRIuADDR

#define TARGET_PRIuADDR   PRIu64

Definition at line 338 of file types.h.

◆ TARGET_PRIxADDR

#define TARGET_PRIxADDR   PRIx64

Definition at line 340 of file types.h.

◆ TARGET_PRIXADDR

#define TARGET_PRIXADDR   PRIX64

Definition at line 341 of file types.h.

◆ true

#define true   1

Definition at line 39 of file types.h.

Typedef Documentation

◆ target_addr_t

typedef uint64_t target_addr_t

Definition at line 335 of file types.h.

Function Documentation

◆ be_to_h_u16()

static uint16_t be_to_h_u16 ( const uint8_t *  buf)
inlinestatic

◆ be_to_h_u24()

static uint32_t be_to_h_u24 ( const uint8_t *  buf)
inlinestatic

Definition at line 144 of file types.h.

Referenced by stm8_read_regs(), and target_buffer_get_u24().

◆ be_to_h_u32()

◆ be_to_h_u64()

static uint64_t be_to_h_u64 ( const uint8_t *  buf)
inlinestatic

Definition at line 127 of file types.h.

Referenced by target_buffer_get_u64().

◆ buf_bswap16()

static void buf_bswap16 ( uint8_t *  dst,
const uint8_t *  src,
size_t  len 
)
inlinestatic

Byte-swap buffer 16-bit.

Len must be even, dst and src must be either the same or non-overlapping.

Parameters
dstDestination buffer.
srcSource buffer.
lenLength of source (and destination) buffer, in bytes.

Definition at line 229 of file types.h.

References be_to_h_u16(), and h_u16_to_le().

Referenced by cfi_write(), or1k_adv_jtag_read_memory(), and or1k_adv_jtag_write_memory().

◆ buf_bswap32()

static void buf_bswap32 ( uint8_t *  dst,
const uint8_t *  src,
size_t  len 
)
inlinestatic

Byte-swap buffer 32-bit.

Len must be divisible by four, dst and src must be either the same or non-overlapping.

Parameters
dstDestination buffer.
srcSource buffer.
lenLength of source (and destination) buffer, in bytes.

Definition at line 249 of file types.h.

References be_to_h_u32(), and h_u32_to_le().

Referenced by cfi_write(), or1k_adv_jtag_read_memory(), or1k_adv_jtag_write_memory(), rpc_hf_xfer(), xtensa_read_memory(), and xtensa_write_memory().

◆ h_u16_to_be()

◆ h_u16_to_le()

◆ h_u24_to_be()

static void h_u24_to_be ( uint8_t *  buf,
unsigned int  val 
)
inlinestatic

Definition at line 201 of file types.h.

Referenced by stm8_write_regs(), and target_buffer_set_u24().

◆ h_u24_to_le()

◆ h_u32_to_be()

◆ h_u32_to_le()

static void h_u32_to_le ( uint8_t *  buf,
uint32_t  val 
)
inlinestatic

Definition at line 178 of file types.h.

Referenced by arm7_9_endianness_callback(), arm7_9_target_request_data(), buf_bswap32(), cmsis_dap_cmd_dap_swj_clock(), cmsis_dap_cmd_dap_swj_pins(), cmsis_dap_cmd_dap_swo_baudrate(), cmsis_dap_metacmd_targetsel(), cmsis_dap_swd_write_from_queue(), h_to_le_32(), icdi_usb_state(), icdi_usb_write_reg(), isc_program_single_revision_btc(), jtag_vpi_send_cmd(), lattice_ecp2_3_write_usercode(), lattice_ecp5_write_usercode(), lattice_read_u32_register(), nrf5_info_variant_to_str(), nulink_speed(), nulink_usb_assert_srst(), nulink_usb_halt(), nulink_usb_idcode(), nulink_usb_read_mem32(), nulink_usb_read_mem8(), nulink_usb_read_reg(), nulink_usb_reset(), nulink_usb_run(), nulink_usb_state(), nulink_usb_step(), nulink_usb_write_mem32(), nulink_usb_write_mem8(), nulink_usb_write_reg(), riscv_init_target(), stlink_set_com_freq(), stlink_tcp_close(), stlink_tcp_xfer_noerrcheck(), stlink_usb_buf_rw_segment(), stlink_usb_misc_rw_segment(), stlink_usb_read_mem16(), stlink_usb_read_mem32(), stlink_usb_read_mem32_noaddrinc(), stlink_usb_read_mem8(), stlink_usb_rw_misc_out(), stlink_usb_trace_enable(), stlink_usb_v2_read_debug_reg(), stlink_usb_write_debug_reg(), stlink_usb_write_mem16(), stlink_usb_write_mem32(), stlink_usb_write_mem32_noaddrinc(), stlink_usb_write_mem8(), stlink_usb_write_reg(), target_buffer_set_u32(), vdebug_jtag_clock(), vdebug_mem_close(), vdebug_open(), vdebug_reg_write(), vdebug_run_jtag_queue(), vdebug_run_reg_queue(), vdebug_sig_set(), and vdebug_wait().

◆ h_u64_to_be()

static void h_u64_to_be ( uint8_t *  buf,
uint64_t  val 
)
inlinestatic

Definition at line 166 of file types.h.

Referenced by target_buffer_set_u64().

◆ h_u64_to_le()

static void h_u64_to_le ( uint8_t *  buf,
uint64_t  val 
)
inlinestatic

◆ le_to_h_u16()

◆ le_to_h_u24()

static uint32_t le_to_h_u24 ( const uint8_t *  buf)
inlinestatic

Definition at line 117 of file types.h.

Referenced by jtagspi_probe(), and target_buffer_get_u24().

◆ le_to_h_u32()

◆ le_to_h_u64()

static uint64_t le_to_h_u64 ( const uint8_t *  buf)
inlinestatic

◆ parity_u32()

static int parity_u32 ( uint32_t  x)
inlinestatic

Calculate the (even) parity of a 32-bit datum.

Parameters
xThe datum.
Returns
1 if the number of set bits in x is odd, 0 if it is even.

Definition at line 265 of file types.h.

Referenced by bitbang_swd_read_reg(), bitbang_swd_write_reg(), buspirate_swd_read_reg(), buspirate_swd_write_reg(), cmsis_dap_metacmd_targetsel(), ftdi_swd_queue_cmd(), ftdi_swd_run_queue(), jlink_swd_run_queue(), swd_cmd(), xlnx_pcie_xvc_swd_read_reg(), and xlnx_pcie_xvc_swd_write_reg().