Skip to content

Commit 417ff40

Browse files
authored
Merge pull request riscv-collab#1150 from borneoa/riscv
target: riscv: convert 'unsigned' to 'unsigned int'
2 parents a4020f1 + 89fb921 commit 417ff40

File tree

6 files changed

+58
-58
lines changed

6 files changed

+58
-58
lines changed

src/target/riscv/opcodes.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -194,26 +194,26 @@ static uint32_t fld(unsigned int dest, unsigned int base, uint16_t offset)
194194
return imm_i(offset) | inst_rs1(base) | inst_rd(dest) | MATCH_FLD;
195195
}
196196

197-
static uint32_t fmv_x_w(unsigned dest, unsigned src) __attribute__ ((unused));
198-
static uint32_t fmv_x_w(unsigned dest, unsigned src)
197+
static uint32_t fmv_x_w(unsigned int dest, unsigned int src) __attribute__ ((unused));
198+
static uint32_t fmv_x_w(unsigned int dest, unsigned int src)
199199
{
200200
return inst_rs1(src) | inst_rd(dest) | MATCH_FMV_X_W;
201201
}
202202

203-
static uint32_t fmv_x_d(unsigned dest, unsigned src) __attribute__ ((unused));
204-
static uint32_t fmv_x_d(unsigned dest, unsigned src)
203+
static uint32_t fmv_x_d(unsigned int dest, unsigned int src) __attribute__ ((unused));
204+
static uint32_t fmv_x_d(unsigned int dest, unsigned int src)
205205
{
206206
return inst_rs1(src) | inst_rd(dest) | MATCH_FMV_X_D;
207207
}
208208

209-
static uint32_t fmv_w_x(unsigned dest, unsigned src) __attribute__ ((unused));
210-
static uint32_t fmv_w_x(unsigned dest, unsigned src)
209+
static uint32_t fmv_w_x(unsigned int dest, unsigned int src) __attribute__ ((unused));
210+
static uint32_t fmv_w_x(unsigned int dest, unsigned int src)
211211
{
212212
return inst_rs1(src) | inst_rd(dest) | MATCH_FMV_W_X;
213213
}
214214

215-
static uint32_t fmv_d_x(unsigned dest, unsigned src) __attribute__ ((unused));
216-
static uint32_t fmv_d_x(unsigned dest, unsigned src)
215+
static uint32_t fmv_d_x(unsigned int dest, unsigned int src) __attribute__ ((unused));
216+
static uint32_t fmv_d_x(unsigned int dest, unsigned int src)
217217
{
218218
return inst_rs1(src) | inst_rd(dest) | MATCH_FMV_D_X;
219219
}

src/target/riscv/program.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ int riscv_program_init(struct riscv_program *p, struct target *target)
3030

3131
int riscv_program_write(struct riscv_program *program)
3232
{
33-
for (unsigned i = 0; i < program->instruction_count; ++i) {
33+
for (unsigned int i = 0; i < program->instruction_count; ++i) {
3434
LOG_TARGET_DEBUG(program->target, "progbuf[%02x] = DASM(0x%08x)",
3535
i, program->progbuf[i]);
3636
if (riscv_write_progbuf(program->target, i, program->progbuf[i]) != ERROR_OK)

src/target/riscv/riscv-011.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ static uint64_t dbus_read(struct target *target, uint16_t address)
443443
* While somewhat nonintuitive, this is an efficient way to get the data.
444444
*/
445445

446-
unsigned i = 0;
446+
unsigned int i = 0;
447447
do {
448448
status = dbus_scan(target, &address_in, &value, DBUS_OP_READ, address, 0);
449449
if (status == DBUS_STATUS_BUSY)
@@ -464,7 +464,7 @@ static uint64_t dbus_read(struct target *target, uint16_t address)
464464
static void dbus_write(struct target *target, uint16_t address, uint64_t value)
465465
{
466466
dbus_status_t status = DBUS_STATUS_BUSY;
467-
unsigned i = 0;
467+
unsigned int i = 0;
468468
while (status == DBUS_STATUS_BUSY && i++ < 256) {
469469
status = dbus_scan(target, NULL, NULL, DBUS_OP_WRITE, address, value);
470470
if (status == DBUS_STATUS_BUSY)
@@ -625,13 +625,13 @@ static void scans_add_read(scans_t *scans, slot_t slot, bool set_interrupt)
625625
}
626626

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

633633
static uint64_t scans_get_u64(scans_t *scans, unsigned int index,
634-
unsigned first, unsigned num)
634+
unsigned int first, unsigned int num)
635635
{
636636
return buf_get_u64(scans->in + scans->scan_size * index, first, num);
637637
}
@@ -663,7 +663,7 @@ static int read_bits(struct target *target, bits_t *result)
663663
riscv011_info_t *info = get_info(target);
664664

665665
do {
666-
unsigned i = 0;
666+
unsigned int i = 0;
667667
do {
668668
status = dbus_scan(target, &address_in, &value, DBUS_OP_READ, 0, 0);
669669
if (status == DBUS_STATUS_BUSY) {
@@ -1257,7 +1257,7 @@ static int register_write(struct target *target, unsigned int number,
12571257
int result = update_mstatus_actual(target);
12581258
if (result != ERROR_OK)
12591259
return result;
1260-
unsigned i = 0;
1260+
unsigned int i = 0;
12611261
if ((info->mstatus_actual & MSTATUS_FS) == 0) {
12621262
info->mstatus_actual = set_field(info->mstatus_actual, MSTATUS_FS, 1);
12631263
cache_set_load(target, i++, S0, SLOT1);
@@ -1318,7 +1318,7 @@ int riscv011_get_register(struct target *target, riscv_reg_t *value,
13181318
int result = update_mstatus_actual(target);
13191319
if (result != ERROR_OK)
13201320
return result;
1321-
unsigned i = 0;
1321+
unsigned int i = 0;
13221322
if ((info->mstatus_actual & MSTATUS_FS) == 0) {
13231323
info->mstatus_actual = set_field(info->mstatus_actual, MSTATUS_FS, 1);
13241324
cache_set_load(target, i++, S0, SLOT1);
@@ -1522,7 +1522,7 @@ static int examine(struct target *target)
15221522
/* 0x00000000 0x00000000:00000003 0x00000000:00000003:ffffffff:ffffffff */
15231523
cache_set32(target, 4, sw(S1, ZERO, DEBUG_RAM_START + 4));
15241524
cache_set_jump(target, 5);
1525-
for (unsigned i = 6; i < info->dramsize; i++)
1525+
for (unsigned int i = 6; i < info->dramsize; i++)
15261526
cache_set32(target, i, i * 0x01020304);
15271527

15281528
cache_write(target, 0, false);
@@ -1553,7 +1553,7 @@ static int examine(struct target *target)
15531553
LOG_DEBUG("Discovered XLEN is %d", riscv_xlen(target));
15541554

15551555
if (read_remote_csr(target, &r->misa, CSR_MISA) != ERROR_OK) {
1556-
const unsigned old_csr_misa = 0xf10;
1556+
const unsigned int old_csr_misa = 0xf10;
15571557
LOG_WARNING("Failed to read misa at 0x%x; trying 0x%x.", CSR_MISA,
15581558
old_csr_misa);
15591559
if (read_remote_csr(target, &r->misa, old_csr_misa) != ERROR_OK) {
@@ -1632,7 +1632,7 @@ static riscv_error_t handle_halt_routine(struct target *target)
16321632

16331633
unsigned int dbus_busy = 0;
16341634
unsigned int interrupt_set = 0;
1635-
unsigned result = 0;
1635+
unsigned int result = 0;
16361636
uint64_t value = 0;
16371637
reg_cache_set(target, 0, 0);
16381638
/* The first scan result is the result from something old we don't care
@@ -2004,7 +2004,7 @@ static int read_memory(struct target *target, target_addr_t address,
20042004
cache_write(target, CACHE_NO_READ, false);
20052005

20062006
riscv011_info_t *info = get_info(target);
2007-
const unsigned max_batch_size = 256;
2007+
const unsigned int max_batch_size = 256;
20082008
scans_t *scans = scans_new(target, max_batch_size);
20092009
if (!scans)
20102010
return ERROR_FAIL;
@@ -2162,7 +2162,7 @@ static int write_memory(struct target *target, target_addr_t address,
21622162
if (setup_write_memory(target, size) != ERROR_OK)
21632163
return ERROR_FAIL;
21642164

2165-
const unsigned max_batch_size = 256;
2165+
const unsigned int max_batch_size = 256;
21662166
scans_t *scans = scans_new(target, max_batch_size);
21672167
if (!scans)
21682168
return ERROR_FAIL;

src/target/riscv/riscv-013.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,11 @@ typedef struct {
150150

151151
typedef struct {
152152
/* The indexed used to address this hart in its DM. */
153-
unsigned index;
153+
unsigned int index;
154154
/* Number of address bits in the dbus register. */
155-
unsigned abits;
155+
unsigned int abits;
156156
/* Number of abstract command data registers. */
157-
unsigned datacount;
157+
unsigned int datacount;
158158
/* Number of words in the Program Buffer. */
159159
unsigned int progbufsize;
160160
/* Hart contains an implicit ebreak at the end of the program buffer. */
@@ -514,7 +514,7 @@ static int increase_ac_busy_delay(struct target *target)
514514
RISCV_DELAY_ABSTRACT_COMMAND);
515515
}
516516

517-
static uint32_t __attribute__((unused)) abstract_register_size(unsigned width)
517+
static uint32_t __attribute__((unused)) abstract_register_size(unsigned int width)
518518
{
519519
switch (width) {
520520
case 32:
@@ -738,10 +738,10 @@ static void abstract_data_write_fill_batch(struct riscv_batch *batch,
738738
}
739739

740740
/* TODO: reuse "abstract_data_write_fill_batch()" here*/
741-
static int write_abstract_arg(struct target *target, unsigned index,
742-
riscv_reg_t value, unsigned size_bits)
741+
static int write_abstract_arg(struct target *target, unsigned int index,
742+
riscv_reg_t value, unsigned int size_bits)
743743
{
744-
unsigned offset = index * size_bits / 32;
744+
unsigned int offset = index * size_bits / 32;
745745
switch (size_bits) {
746746
default:
747747
LOG_TARGET_ERROR(target, "Unsupported size: %d bits", size_bits);
@@ -759,7 +759,7 @@ static int write_abstract_arg(struct target *target, unsigned index,
759759
* @par size in bits
760760
*/
761761
uint32_t riscv013_access_register_command(struct target *target, uint32_t number,
762-
unsigned size, uint32_t flags)
762+
unsigned int size, uint32_t flags)
763763
{
764764
uint32_t command = set_field(0, DM_COMMAND_CMDTYPE, 0);
765765
switch (size) {
@@ -907,7 +907,7 @@ static int register_write_abstract(struct target *target, enum gdb_regno number,
907907
* Sets the AAMSIZE field of a memory access abstract command based on
908908
* the width (bits).
909909
*/
910-
static uint32_t abstract_memory_size(unsigned width)
910+
static uint32_t abstract_memory_size(unsigned int width)
911911
{
912912
switch (width) {
913913
case 8:
@@ -1089,7 +1089,7 @@ typedef struct {
10891089
static int scratch_reserve(struct target *target,
10901090
scratch_mem_t *scratch,
10911091
struct riscv_program *program,
1092-
unsigned size_bytes)
1092+
unsigned int size_bytes)
10931093
{
10941094
riscv_addr_t alignment = 1;
10951095
while (alignment < size_bytes)
@@ -1121,7 +1121,7 @@ static int scratch_reserve(struct target *target,
11211121
return ERROR_FAIL;
11221122

11231123
/* Allow for ebreak at the end of the program. */
1124-
unsigned program_size = (program->instruction_count + 1) * 4;
1124+
unsigned int program_size = (program->instruction_count + 1) * 4;
11251125
scratch->hart_address = (info->progbuf_address + program_size + alignment - 1) &
11261126
~(alignment - 1);
11271127
if ((info->progbuf_writable == YNM_YES) &&
@@ -1237,7 +1237,7 @@ static unsigned int register_size(struct target *target, enum gdb_regno number)
12371237
return riscv_xlen(target);
12381238
}
12391239

1240-
static bool has_sufficient_progbuf(struct target *target, unsigned size)
1240+
static bool has_sufficient_progbuf(struct target *target, unsigned int size)
12411241
{
12421242
RISCV013_INFO(info);
12431243
return info->progbufsize + info->impebreak >= size;
@@ -2085,7 +2085,7 @@ static int riscv013_authdata_write(struct target *target, uint32_t value, unsign
20852085
}
20862086

20872087
/* Try to find out the widest memory access size depending on the selected memory access methods. */
2088-
static unsigned riscv013_data_bits(struct target *target)
2088+
static unsigned int riscv013_data_bits(struct target *target)
20892089
{
20902090
RISCV013_INFO(info);
20912091
RISCV_INFO(r);
@@ -3022,7 +3022,7 @@ static int read_memory_bus_word(struct target *target, target_addr_t address,
30223022
static target_addr_t sb_read_address(struct target *target)
30233023
{
30243024
RISCV013_INFO(info);
3025-
unsigned sbasize = get_field(info->sbcs, DM_SBCS_SBASIZE);
3025+
unsigned int sbasize = get_field(info->sbcs, DM_SBCS_SBASIZE);
30263026
target_addr_t address = 0;
30273027
uint32_t v;
30283028
if (sbasize > 32) {
@@ -3296,7 +3296,7 @@ static int read_memory_bus_v1(struct target *target, target_addr_t address,
32963296
continue;
32973297
}
32983298

3299-
unsigned error = get_field(sbcs_read, DM_SBCS_SBERROR);
3299+
unsigned int error = get_field(sbcs_read, DM_SBCS_SBERROR);
33003300
if (error == DM_SBCS_SBERROR_NONE) {
33013301
next_address = end_address;
33023302
} else {
@@ -3535,7 +3535,7 @@ read_memory_abstract(struct target *target, target_addr_t address,
35353535
memset(buffer, 0, count * size);
35363536

35373537
/* Convert the size (bytes) to width (bits) */
3538-
unsigned width = size << 3;
3538+
unsigned int width = size << 3;
35393539

35403540
/* Create the command (physical address, postincrement, read) */
35413541
uint32_t command = access_memory_command(target, false, width, use_aampostincrement, false);
@@ -3632,7 +3632,7 @@ write_memory_abstract(struct target *target, target_addr_t address,
36323632
size, address);
36333633

36343634
/* Convert the size (bytes) to width (bits) */
3635-
unsigned width = size << 3;
3635+
unsigned int width = size << 3;
36363636

36373637
/* Create the command (physical address, postincrement, write) */
36383638
uint32_t command = access_memory_command(target, false, width, use_aampostincrement, true);
@@ -5047,13 +5047,13 @@ static int select_prepped_harts(struct target *target)
50475047
}
50485048

50495049
assert(dm->hart_count);
5050-
unsigned hawindow_count = (dm->hart_count + 31) / 32;
5050+
unsigned int hawindow_count = (dm->hart_count + 31) / 32;
50515051
uint32_t *hawindow = calloc(hawindow_count, sizeof(uint32_t));
50525052
if (!hawindow)
50535053
return ERROR_FAIL;
50545054

50555055
target_list_t *entry;
5056-
unsigned total_selected = 0;
5056+
unsigned int total_selected = 0;
50575057
unsigned int selected_index = 0;
50585058
list_for_each_entry(entry, &dm->target_list, list) {
50595059
struct target *t = entry->target;
@@ -5085,7 +5085,7 @@ static int select_prepped_harts(struct target *target)
50855085
return ERROR_FAIL;
50865086
}
50875087

5088-
for (unsigned i = 0; i < hawindow_count; i++) {
5088+
for (unsigned int i = 0; i < hawindow_count; i++) {
50895089
if (dm_write(target, DM_HAWINDOWSEL, i) != ERROR_OK) {
50905090
free(hawindow);
50915091
return ERROR_FAIL;

src/target/riscv/riscv.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3298,7 +3298,7 @@ static int riscv_run_algorithm(struct target *target, int num_mem_params,
32983298
GDB_REGNO_PC,
32993299
GDB_REGNO_MSTATUS, GDB_REGNO_MEPC, GDB_REGNO_MCAUSE,
33003300
};
3301-
for (unsigned i = 0; i < ARRAY_SIZE(regnums); i++) {
3301+
for (unsigned int i = 0; i < ARRAY_SIZE(regnums); i++) {
33023302
enum gdb_regno regno = regnums[i];
33033303
riscv_reg_t reg_value;
33043304
if (riscv_reg_get(target, &reg_value, regno) != ERROR_OK)
@@ -3393,8 +3393,8 @@ static int riscv_checksum_memory(struct target *target,
33933393

33943394
static const uint8_t *crc_code;
33953395

3396-
unsigned xlen = riscv_xlen(target);
3397-
unsigned crc_code_size;
3396+
unsigned int xlen = riscv_xlen(target);
3397+
unsigned int crc_code_size;
33983398
if (xlen == 32) {
33993399
crc_code = riscv32_crc_code;
34003400
crc_code_size = sizeof(riscv32_crc_code);
@@ -3957,8 +3957,8 @@ static int parse_ranges(struct list_head *ranges, const char *tcl_arg, const cha
39573957
/* For backward compatibility, allow multiple parameters within one TCL argument, separated by ',' */
39583958
char *arg = strtok(args, ",");
39593959
while (arg) {
3960-
unsigned low = 0;
3961-
unsigned high = 0;
3960+
unsigned int low = 0;
3961+
unsigned int high = 0;
39623962
char *name = NULL;
39633963

39643964
char *dash = strchr(arg, '-');
@@ -5578,7 +5578,7 @@ static int riscv_step_rtos_hart(struct target *target)
55785578
bool riscv_supports_extension(const struct target *target, char letter)
55795579
{
55805580
RISCV_INFO(r);
5581-
unsigned num;
5581+
unsigned int num;
55825582
if (letter >= 'a' && letter <= 'z')
55835583
num = letter - 'a';
55845584
else if (letter >= 'A' && letter <= 'Z')
@@ -5588,7 +5588,7 @@ bool riscv_supports_extension(const struct target *target, char letter)
55885588
return r->misa & BIT(num);
55895589
}
55905590

5591-
unsigned riscv_xlen(const struct target *target)
5591+
unsigned int riscv_xlen(const struct target *target)
55925592
{
55935593
RISCV_INFO(r);
55945594
return r->xlen;

src/target/riscv/riscv.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ struct riscv_info {
245245
int (*read_memory)(struct target *target, target_addr_t address,
246246
uint32_t size, uint32_t count, uint8_t *buffer, uint32_t increment);
247247

248-
unsigned (*data_bits)(struct target *target);
248+
unsigned int (*data_bits)(struct target *target);
249249

250250
COMMAND_HELPER((*print_info), struct target *target);
251251

@@ -320,15 +320,15 @@ typedef struct {
320320
typedef struct {
321321
const char *name;
322322
int level;
323-
unsigned va_bits;
323+
unsigned int va_bits;
324324
/* log2(PTESIZE) */
325-
unsigned pte_shift;
326-
unsigned vpn_shift[PG_MAX_LEVEL];
327-
unsigned vpn_mask[PG_MAX_LEVEL];
328-
unsigned pte_ppn_shift[PG_MAX_LEVEL];
329-
unsigned pte_ppn_mask[PG_MAX_LEVEL];
330-
unsigned pa_ppn_shift[PG_MAX_LEVEL];
331-
unsigned pa_ppn_mask[PG_MAX_LEVEL];
325+
unsigned int pte_shift;
326+
unsigned int vpn_shift[PG_MAX_LEVEL];
327+
unsigned int vpn_mask[PG_MAX_LEVEL];
328+
unsigned int pte_ppn_shift[PG_MAX_LEVEL];
329+
unsigned int pte_ppn_mask[PG_MAX_LEVEL];
330+
unsigned int pa_ppn_shift[PG_MAX_LEVEL];
331+
unsigned int pa_ppn_mask[PG_MAX_LEVEL];
332332
} virt2phys_info_t;
333333

334334
/* Wall-clock timeout for a command/access. Settable via RISC-V Target commands.*/
@@ -381,7 +381,7 @@ int riscv_openocd_step(
381381
bool riscv_supports_extension(const struct target *target, char letter);
382382

383383
/* Returns XLEN for the given (or current) hart. */
384-
unsigned riscv_xlen(const struct target *target);
384+
unsigned int riscv_xlen(const struct target *target);
385385

386386
/* Returns VLENB for the given (or current) hart. */
387387
unsigned int riscv_vlenb(const struct target *target);

0 commit comments

Comments
 (0)