Skip to content

Commit

Permalink
target: riscv: convert 'unsigned' to 'unsigned int'
Browse files Browse the repository at this point in the history
Conversion done with
	checkpatch --fix-inplace -types UNSPECIFIED_INT

Ignore the cast as they could be better addressed.
Fix only minor additional checkpatch issue (spacing and line
length).

Change-Id: I11f10eddadc21e051c96eb3d4d4c0554a2cddd15
Signed-off-by: Antonio Borneo <[email protected]>
Reviewed-on: https://review.openocd.org/c/openocd/+/8483
Tested-by: jenkins
  • Loading branch information
borneoa committed Oct 20, 2024
1 parent bcf63ac commit 957eb74
Show file tree
Hide file tree
Showing 8 changed files with 121 additions and 121 deletions.
6 changes: 3 additions & 3 deletions src/target/riscv/batch.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ int riscv_batch_run(struct riscv_batch *batch)
return ERROR_OK;
}

void riscv_batch_add_dmi_write(struct riscv_batch *batch, unsigned address, uint64_t data)
void riscv_batch_add_dmi_write(struct riscv_batch *batch, unsigned int address, uint64_t data)
{
assert(batch->used_scans < batch->allocated_scans);
struct scan_field *field = batch->fields + batch->used_scans;
Expand All @@ -140,7 +140,7 @@ void riscv_batch_add_dmi_write(struct riscv_batch *batch, unsigned address, uint
batch->used_scans++;
}

size_t riscv_batch_add_dmi_read(struct riscv_batch *batch, unsigned address)
size_t riscv_batch_add_dmi_read(struct riscv_batch *batch, unsigned int address)
{
assert(batch->used_scans < batch->allocated_scans);
struct scan_field *field = batch->fields + batch->used_scans;
Expand All @@ -156,7 +156,7 @@ size_t riscv_batch_add_dmi_read(struct riscv_batch *batch, unsigned address)
return batch->read_keys_used++;
}

unsigned riscv_batch_get_dmi_read_op(struct riscv_batch *batch, size_t key)
unsigned int riscv_batch_get_dmi_read_op(struct riscv_batch *batch, size_t key)
{
assert(key < batch->read_keys_used);
size_t index = batch->read_keys[key];
Expand Down
6 changes: 3 additions & 3 deletions src/target/riscv/batch.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ bool riscv_batch_full(struct riscv_batch *batch);
int riscv_batch_run(struct riscv_batch *batch);

/* Adds a DMI write to this batch. */
void riscv_batch_add_dmi_write(struct riscv_batch *batch, unsigned address, uint64_t data);
void riscv_batch_add_dmi_write(struct riscv_batch *batch, unsigned int address, uint64_t data);

/* DMI reads must be handled in two parts: the first one schedules a read and
* provides a key, the second one actually obtains the result of the read -
* status (op) and the actual data. */
size_t riscv_batch_add_dmi_read(struct riscv_batch *batch, unsigned address);
unsigned riscv_batch_get_dmi_read_op(struct riscv_batch *batch, size_t key);
size_t riscv_batch_add_dmi_read(struct riscv_batch *batch, unsigned int address);
unsigned int riscv_batch_get_dmi_read_op(struct riscv_batch *batch, size_t key);
uint32_t riscv_batch_get_dmi_read_data(struct riscv_batch *batch, size_t key);

/* Scans in a NOP. */
Expand Down
16 changes: 8 additions & 8 deletions src/target/riscv/opcodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,26 +191,26 @@ static uint32_t fld(unsigned int dest, unsigned int base, uint16_t offset)
return imm_i(offset) | inst_rs1(base) | inst_rd(dest) | MATCH_FLD;
}

static uint32_t fmv_x_w(unsigned dest, unsigned src) __attribute__ ((unused));
static uint32_t fmv_x_w(unsigned dest, unsigned src)
static uint32_t fmv_x_w(unsigned int dest, unsigned int src) __attribute__ ((unused));
static uint32_t fmv_x_w(unsigned int dest, unsigned int src)
{
return inst_rs1(src) | inst_rd(dest) | MATCH_FMV_X_W;
}

static uint32_t fmv_x_d(unsigned dest, unsigned src) __attribute__ ((unused));
static uint32_t fmv_x_d(unsigned dest, unsigned src)
static uint32_t fmv_x_d(unsigned int dest, unsigned int src) __attribute__ ((unused));
static uint32_t fmv_x_d(unsigned int dest, unsigned int src)
{
return inst_rs1(src) | inst_rd(dest) | MATCH_FMV_X_D;
}

static uint32_t fmv_w_x(unsigned dest, unsigned src) __attribute__ ((unused));
static uint32_t fmv_w_x(unsigned dest, unsigned src)
static uint32_t fmv_w_x(unsigned int dest, unsigned int src) __attribute__ ((unused));
static uint32_t fmv_w_x(unsigned int dest, unsigned int src)
{
return inst_rs1(src) | inst_rd(dest) | MATCH_FMV_W_X;
}

static uint32_t fmv_d_x(unsigned dest, unsigned src) __attribute__ ((unused));
static uint32_t fmv_d_x(unsigned dest, unsigned src)
static uint32_t fmv_d_x(unsigned int dest, unsigned int src) __attribute__ ((unused));
static uint32_t fmv_d_x(unsigned int dest, unsigned int src)
{
return inst_rs1(src) | inst_rd(dest) | MATCH_FMV_D_X;
}
Expand Down
2 changes: 1 addition & 1 deletion src/target/riscv/program.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ int riscv_program_init(struct riscv_program *p, struct target *target)

int riscv_program_write(struct riscv_program *program)
{
for (unsigned i = 0; i < program->instruction_count; ++i) {
for (unsigned int i = 0; i < program->instruction_count; ++i) {
LOG_DEBUG("debug_buffer[%02x] = DASM(0x%08x)", i, program->debug_buffer[i]);
if (riscv_write_debug_buffer(program->target, i,
program->debug_buffer[i]) != ERROR_OK)
Expand Down
24 changes: 12 additions & 12 deletions src/target/riscv/riscv-011.c
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ static uint64_t dbus_read(struct target *target, uint16_t address)
* While somewhat nonintuitive, this is an efficient way to get the data.
*/

unsigned i = 0;
unsigned int i = 0;
do {
status = dbus_scan(target, &address_in, &value, DBUS_OP_READ, address, 0);
if (status == DBUS_STATUS_BUSY)
Expand All @@ -495,7 +495,7 @@ static uint64_t dbus_read(struct target *target, uint16_t address)
static void dbus_write(struct target *target, uint16_t address, uint64_t value)
{
dbus_status_t status = DBUS_STATUS_BUSY;
unsigned i = 0;
unsigned int i = 0;
while (status == DBUS_STATUS_BUSY && i++ < 256) {
status = dbus_scan(target, NULL, NULL, DBUS_OP_WRITE, address, value);
if (status == DBUS_STATUS_BUSY)
Expand Down Expand Up @@ -656,13 +656,13 @@ static void scans_add_read(scans_t *scans, slot_t slot, bool set_interrupt)
}

static uint32_t scans_get_u32(scans_t *scans, unsigned int index,
unsigned first, unsigned num)
unsigned int first, unsigned int num)
{
return buf_get_u32(scans->in + scans->scan_size * index, first, num);
}

static uint64_t scans_get_u64(scans_t *scans, unsigned int index,
unsigned first, unsigned num)
unsigned int first, unsigned int num)
{
return buf_get_u64(scans->in + scans->scan_size * index, first, num);
}
Expand Down Expand Up @@ -699,7 +699,7 @@ static bits_t read_bits(struct target *target)
};

do {
unsigned i = 0;
unsigned int i = 0;
do {
status = dbus_scan(target, &address_in, &value, DBUS_OP_READ, 0, 0);
if (status == DBUS_STATUS_BUSY) {
Expand Down Expand Up @@ -1296,7 +1296,7 @@ static int register_write(struct target *target, unsigned int number,
int result = update_mstatus_actual(target);
if (result != ERROR_OK)
return result;
unsigned i = 0;
unsigned int i = 0;
if ((info->mstatus_actual & MSTATUS_FS) == 0) {
info->mstatus_actual = set_field(info->mstatus_actual, MSTATUS_FS, 1);
cache_set_load(target, i++, S0, SLOT1);
Expand Down Expand Up @@ -1352,7 +1352,7 @@ static int get_register(struct target *target, riscv_reg_t *value, int regid)
int result = update_mstatus_actual(target);
if (result != ERROR_OK)
return result;
unsigned i = 0;
unsigned int i = 0;
if ((info->mstatus_actual & MSTATUS_FS) == 0) {
info->mstatus_actual = set_field(info->mstatus_actual, MSTATUS_FS, 1);
cache_set_load(target, i++, S0, SLOT1);
Expand Down Expand Up @@ -1538,7 +1538,7 @@ static int examine(struct target *target)
/* 0x00000000 0x00000000:00000003 0x00000000:00000003:ffffffff:ffffffff */
cache_set32(target, 4, sw(S1, ZERO, DEBUG_RAM_START + 4));
cache_set_jump(target, 5);
for (unsigned i = 6; i < info->dramsize; i++)
for (unsigned int i = 6; i < info->dramsize; i++)
cache_set32(target, i, i * 0x01020304);

cache_write(target, 0, false);
Expand Down Expand Up @@ -1569,7 +1569,7 @@ static int examine(struct target *target)
LOG_DEBUG("Discovered XLEN is %d", riscv_xlen(target));

if (read_remote_csr(target, &r->misa, CSR_MISA) != ERROR_OK) {
const unsigned old_csr_misa = 0xf10;
const unsigned int old_csr_misa = 0xf10;
LOG_WARNING("Failed to read misa at 0x%x; trying 0x%x.", CSR_MISA,
old_csr_misa);
if (read_remote_csr(target, &r->misa, old_csr_misa) != ERROR_OK) {
Expand Down Expand Up @@ -1651,7 +1651,7 @@ static riscv_error_t handle_halt_routine(struct target *target)

unsigned int dbus_busy = 0;
unsigned int interrupt_set = 0;
unsigned result = 0;
unsigned int result = 0;
uint64_t value = 0;
reg_cache_set(target, 0, 0);
/* The first scan result is the result from something old we don't care
Expand Down Expand Up @@ -2016,7 +2016,7 @@ static int read_memory(struct target *target, target_addr_t address,
cache_write(target, CACHE_NO_READ, false);

riscv011_info_t *info = get_info(target);
const unsigned max_batch_size = 256;
const unsigned int max_batch_size = 256;
scans_t *scans = scans_new(target, max_batch_size);
if (!scans)
return ERROR_FAIL;
Expand Down Expand Up @@ -2174,7 +2174,7 @@ static int write_memory(struct target *target, target_addr_t address,
if (setup_write_memory(target, size) != ERROR_OK)
return ERROR_FAIL;

const unsigned max_batch_size = 256;
const unsigned int max_batch_size = 256;
scans_t *scans = scans_new(target, max_batch_size);
if (!scans)
return ERROR_FAIL;
Expand Down
Loading

0 comments on commit 957eb74

Please sign in to comment.