From 4bd15e7ffbeeb4c419112dc8e2df57cc067c6d34 Mon Sep 17 00:00:00 2001 From: Phillip Stanley-Marbell Date: Mon, 2 Dec 2019 17:40:27 +0000 Subject: [PATCH] Compiler warnings and embedded target tweaks --- sim/fdr.c | 2 +- sim/main.c | 8 ++++---- sim/memory-hierarchy.c | 25 ++++++------------------- sim/op-riscv.c | 26 +++++++++++++------------- sim/syscalls.c | 12 ++++++------ 5 files changed, 30 insertions(+), 43 deletions(-) diff --git a/sim/fdr.c b/sim/fdr.c index 8f4d9897..cf7e3c60 100755 --- a/sim/fdr.c +++ b/sim/fdr.c @@ -585,7 +585,7 @@ m_readstabs(Engine *E, State *S, char *filename) /* */ if ((strlen(line) > 0) && (line[strlen(line)-1] != '\n')) { -#ifndef SF_EMBEDDED +#if (SF_EMBEDDED == 0) fscanf(fp, "%*s\n"); #endif } diff --git a/sim/main.c b/sim/main.c index 98c1d8f2..de0aac72 100755 --- a/sim/main.c +++ b/sim/main.c @@ -498,7 +498,7 @@ updaterandsched(Engine *E) void scheduler(Engine *E) { -#ifndef SF_EMBEDDED +#if (SF_EMBEDDED == 0) int jmpval; #endif @@ -509,7 +509,7 @@ scheduler(Engine *E) /* */ marchinit(); -#ifndef SF_EMBEDDED +#if (SF_EMBEDDED == 0) if (!(jmpval = setjmp(E->jmpbuf))) { /* Returning from initial call */ @@ -832,7 +832,7 @@ savemem(Engine *E, State *S, ulong start_addr, ulong end_addr, char *filename) void sfatal(Engine *E, State *S, char *msg) { -#ifndef SF_EMBEDDED +#if (SF_EMBEDDED == 0) int do_jmp = E->on; #endif @@ -859,7 +859,7 @@ sfatal(Engine *E, State *S, char *msg) /* Don't longjmp when, e.g., loading a file into mem, in */ /* which case we'd have entered sfatal w/ E->on false. */ /* */ -#ifndef SF_EMBEDDED +#if (SF_EMBEDDED == 0) if (do_jmp) { longjmp(E->jmpbuf, S->NODE_ID); diff --git a/sim/memory-hierarchy.c b/sim/memory-hierarchy.c index dbc60e62..241bc5fc 100755 --- a/sim/memory-hierarchy.c +++ b/sim/memory-hierarchy.c @@ -36,7 +36,6 @@ */ -//Read from memory 2 bytes void big_endian_read_2(uchar * source, ushort * target) { @@ -66,7 +65,6 @@ read_2(State * S, uchar * source, ushort * target) } } -//Read from memory 4 bytes void big_endian_read_4(uchar * source, ulong * target) { @@ -97,7 +95,6 @@ read_4(State * S, uchar * source, ulong * target) } -//Write to memory 2 bytes void big_endian_write_2(ushort source, uchar * target) { @@ -130,7 +127,6 @@ write_2(State *S, ushort source, uchar * target) } -//Write to memory 4 bytes void big_endian_write_4(ulong source, uchar * target) { @@ -237,7 +233,7 @@ superHwritebyte(Engine *E, State *S, ulong vaddr, ulong xdata) { int inram, latency = 0; int i, j, id; - ulong offset, destbase, destoffset; + ulong offset, destoffset; TransAddr trans; ulong paddr; uchar data = xdata & 0xFF; @@ -295,7 +291,6 @@ superHwritebyte(Engine *E, State *S, ulong vaddr, ulong xdata) if (i != -1) { - //fprintf(stderr, "!"); X->regions[i]->nwrites++; id = X->regions[i]->map_id; @@ -351,7 +346,6 @@ superHwritebyte(Engine *E, State *S, ulong vaddr, ulong xdata) D = E->sp[id]; - destbase = D->MEMBASE; offset = vaddr - S->MEMBASE; destoffset = offset + X->regions[i]->map_offset; @@ -523,7 +517,7 @@ superHwriteword(Engine *E, State *S, ulong vaddr, ulong xdata) { int inram, latency = 0; int i, id, j; - ulong offset, destoffset = 0, destbase; + ulong offset, destoffset = 0; TransAddr trans; ulong paddr; ushort data = xdata & 0xFFFF; @@ -581,7 +575,6 @@ superHwriteword(Engine *E, State *S, ulong vaddr, ulong xdata) if (i != -1) { - //fprintf(stderr, "!"); X->regions[i]->nwrites++; id = X->regions[i]->map_id; @@ -647,7 +640,6 @@ superHwriteword(Engine *E, State *S, ulong vaddr, ulong xdata) } D = E->sp[id]; - destbase = D->MEMBASE; offset = vaddr - S->MEMBASE; destoffset = offset + X->regions[i]->map_offset; @@ -833,7 +825,7 @@ superHwritelong(Engine *E, State *S, ulong vaddr, ulong data) { int inram, latency = 0; int i, id, j; - ulong offset, destoffset = 0, destbase; + ulong offset, destoffset = 0; TransAddr trans; ulong paddr; State *D; @@ -890,7 +882,6 @@ superHwritelong(Engine *E, State *S, ulong vaddr, ulong data) if (i != -1) { - //fprintf(stderr, "!"); X->regions[i]->nwrites++; id = X->regions[i]->map_id; @@ -956,7 +947,6 @@ superHwritelong(Engine *E, State *S, ulong vaddr, ulong data) } D = E->sp[id]; - destbase = D->MEMBASE; offset = vaddr - S->MEMBASE; destoffset = offset + X->regions[i]->map_offset; @@ -1152,7 +1142,7 @@ superHreadbyte(Engine *E, State *S, ulong vaddr) { int inram, latency = 0; int i, id, j; - ulong offset, destoffset = 0, destbase; + ulong offset, destoffset = 0; TransAddr trans; ulong paddr; uchar data = 0; @@ -1231,7 +1221,6 @@ superHreadbyte(Engine *E, State *S, ulong vaddr) } D = E->sp[id]; - destbase = D->MEMBASE; offset = vaddr - S->MEMBASE; destoffset = offset + X->regions[i]->map_offset; @@ -1423,7 +1412,7 @@ superHreadword(Engine *E, State *S, ulong vaddr) { int inram, latency = 0; int i, id, j; - ulong offset, destoffset = 0, destbase; + ulong offset, destoffset = 0; TransAddr trans; ulong paddr; ushort data = 0; @@ -1502,7 +1491,6 @@ superHreadword(Engine *E, State *S, ulong vaddr) } D = E->sp[id]; - destbase = D->MEMBASE; offset = vaddr - S->MEMBASE; destoffset = offset + X->regions[i]->map_offset; @@ -1716,7 +1704,7 @@ superHreadlong(Engine *E, State *S, ulong vaddr) { int inram, latency = 0; int i, id, j; - ulong offset, destoffset = 0, destbase; + ulong offset, destoffset = 0; TransAddr trans; ulong paddr; ulong data = 0; @@ -1796,7 +1784,6 @@ mprint(E,NULL,siminfo,"map_offset: " UHLONGFMT "\n",X->regions[i]->map_offset); } D = E->sp[id]; - destbase = D->MEMBASE; offset = vaddr - S->MEMBASE; destoffset = offset + X->regions[i]->map_offset; diff --git a/sim/op-riscv.c b/sim/op-riscv.c index 05c7fa25..55023b5b 100644 --- a/sim/op-riscv.c +++ b/sim/op-riscv.c @@ -1337,7 +1337,7 @@ rv32f_fmin_s(Engine *E, State *S, uint8_t rs1, uint8_t rs2, uint8_t rd) merror(E, "We currently do not support unfmin.s. Sorry!"); - uncertain_inst_mv(S->riscv->uncertain, rd, nan("")); + //uncertain_inst_mv(S->riscv->uncertain, rd, nan("")); S->riscv->uncertain->last_op.valid = 0; } @@ -1372,7 +1372,7 @@ rv32f_fmax_s(Engine *E, State *S, uint8_t rs1, uint8_t rs2, uint8_t rd) merror(E, "We currently do not support unfmax.s. Sorry!"); - uncertain_inst_mv(S->riscv->uncertain, rd, nan("")); + //uncertain_inst_mv(S->riscv->uncertain, rd, nan("")); S->riscv->uncertain->last_op.valid = 0; } @@ -1390,9 +1390,9 @@ rv32f_fcvt_w_s(Engine *E, State *S, uint8_t rs1, uint8_t rs2, uint8_t rd) src1.bit_value = is_nan_boxed(freg_read_riscv(E, S, rs1)); /* - *Rounding modes - Reference - *https://www.gnu.org/software/libc/manual/html_node/Rounding-Functions.html - */ + * Rounding modes - Reference + * https://www.gnu.org/software/libc/manual/html_node/Rounding-Functions.html + */ switch (rm) //TODO check rm value for rounding { case 0b000: //Round to nearest (ties to Even) @@ -1478,9 +1478,9 @@ rv32f_fcvt_wu_s(Engine *E, State *S, uint8_t rs1, uint8_t rs2, uint8_t rd) uint8_t rm = ((instr_r *)&S->riscv->P.EX.instr)->funct3; /* - *Rounding modes - Reference - *https://www.gnu.org/software/libc/manual/html_node/Rounding-Functions.html - */ + * Rounding modes - Reference + * https://www.gnu.org/software/libc/manual/html_node/Rounding-Functions.html + */ switch (rm) //TODO check rm value for rounding { case 0b000: //Round to nearest (ties to Even) @@ -1994,7 +1994,7 @@ rv32d_fdiv_d(Engine *E, State *S, uint8_t rs1, uint8_t rs2, uint8_t rd) void rv32d_fsqrt_d(Engine *E, State *S, uint8_t rs1, uint8_t rs2, uint8_t rd) { - //rs2 is unused + //TODO: rs2 is unused uint8_t rm = ((instr_r *)&S->riscv->P.EX.instr)->funct3; rv32d_rep src1, result; @@ -2118,7 +2118,7 @@ rv32d_fcvt_s_d(Engine *E, State *S, uint8_t rs1, uint8_t rs2, uint8_t rd) { //uint8_t rm = ((instr_r *)&S->riscv->P.EX.instr)->funct3; //TODO check why there is a rm field? - //rs2 unused + //TODO: rs2 unused rv32f_rep result; rv32d_rep src1; @@ -2142,7 +2142,7 @@ rv32d_fcvt_d_s(Engine *E, State *S, uint8_t rs1, uint8_t rs2, uint8_t rd) { //uint8_t rm = ((instr_r *)&S->riscv->P.EX.instr)->funct3; //TODO check why there is a rm field? - //rs2 unused + //TODO: rs2 unused rv32d_rep result; rv32f_rep src1; @@ -2272,7 +2272,7 @@ rv32d_fclass_d(Engine *E, State *S, uint8_t rs1, uint8_t rs2, uint8_t rd) void rv32d_fcvt_w_d(Engine *E, State *S, uint8_t rs1, uint8_t rs2, uint8_t rd) { - //rs2 unused + //TODO: rs2 unused rv32d_rep src1; @@ -2445,7 +2445,7 @@ void rv32d_fcvt_d_w(Engine *E, State *S, uint8_t rs1, uint8_t rs2, uint8_t rd) { //uint8_t rm = ((instr_r *)&S->riscv->P.EX.instr)->funct3; //TODO check why there is a rm field? - //rs2 unused + //TODO: rs2 unused rv32d_rep result; int32_t src1 = (int32_t)reg_read_riscv(E, S, rs1); diff --git a/sim/syscalls.c b/sim/syscalls.c index 10b24345..fc0458af 100755 --- a/sim/syscalls.c +++ b/sim/syscalls.c @@ -38,7 +38,7 @@ #include #include #include -#ifndef SF_EMBEDDED +#if (SF_EMBEDDED == 0) # include #endif #include @@ -67,7 +67,7 @@ sim_syscall(Engine *E, State *S, ulong type, ulong arg1, ulong arg2, ulong arg3) { case SYS_exit: { -#ifndef SF_EMBEDDED +#if (SF_EMBEDDED == 0) struct tms t; #endif /* @@ -79,7 +79,7 @@ sim_syscall(Engine *E, State *S, ulong type, ulong arg1, ulong arg2, ulong arg3) mprint(E, S, nodeinfo, "SYSCALL: SYS_exit\n"); } -#ifndef SF_EMBEDDED +#if (SF_EMBEDDED == 0) times(&t); #endif S->ufinish = musercputimeusecs(); @@ -566,7 +566,7 @@ ulong sys_chmod(State *S, const char *path, short mode) { /* For now, just pass it on */ -#ifndef SF_EMBEDDED +#if (SF_EMBEDDED == 0) return chmod((char *)&S->MEM[(ulong)path - S->MEMBASE], mode); #else return 0; @@ -577,7 +577,7 @@ ulong sys_chown(State *S, const char *path, short owner, short group) { /* For now, just pass it on */ -#ifndef SF_EMBEDDED +#if (SF_EMBEDDED == 0) return chown((char *)&S->MEM[(ulong)path - S->MEMBASE], owner, group); #else return 0; @@ -614,7 +614,7 @@ ulong sys_utime(State *S, const char *path, const struct utimbuf *times) { /* For now, just pass it on */ -#ifndef SF_EMBEDDED +#if (SF_EMBEDDED == 0) return utime((char *)&S->MEM[(ulong)path - S->MEMBASE],\ (const struct utimbuf *)&S->MEM[(ulong)times - S->MEMBASE]); #else