Commit Diff


commit - d86f6f86d2eef472b90b0af22f14fedaa5d5d1dd
commit + 37d179b359563f0d6b662285b81c768239dd1c1a
blob - f651b1c7922c5b6b13376d3fefaa03ed2ed1405f
blob + f8ced90bcaa3a38a746c653e9d44a09d2fd308c4
--- .gitignore
+++ .gitignore
@@ -16,4 +16,4 @@ microcoreutils
 *.pdf
 rootfs
 rvemu
-
+config.mk.local
blob - cd04cc43d95dd25d3dafe21a8e5e92fbcd24437f
blob + cc5b1e19fab3265bfb05034c4cc394d07defbbfc
--- src/cpu.c
+++ src/cpu.c
@@ -1,3 +1,4 @@
+#include <inttypes.h>
 #include "rvemu.h"
 
 static u64 regs[31];
@@ -27,7 +28,7 @@ static i64 extend (i32 x)
 	return x;
 }
 
-#define log(fmt, ...) eprintf ("%08llx: " fmt "\n", pc - 4, __VA_ARGS__)
+#define log(fmt, ...) eprintf ("%08"PRIx64": " fmt "\n", pc - 4, __VA_ARGS__)
 void cpu_exec (u32 instr)
 {
 	const char *name;
@@ -54,22 +55,22 @@ void cpu_exec (u32 instr)
 	u64 a, b, c;
 	switch (instr & 0x7f) {
 	case 0b0110111: // lui rd, uimm
-		log ("lui x%u, %llu", (uint)rd, imm_u);
+		log ("lui x%u, %"PRIu64, (uint)rd, imm_u);
 		cpu_set (rd, imm_u);
 		break;
 	case 0b0010111: // auipc rd, uimm
-		log ("auipc x%u, %llu", (uint)rd, imm_u);
+		log ("auipc x%u, %"PRIu64, (uint)rd, imm_u);
 		cpu_set (rd, pc + imm_u - 4);
 		break;
 	case 0b1101111: // jal rd, jimm
-		log ("jal x%u, %lld", (uint)rd, imm_j);
+		log ("jal x%u, %"PRId64, (uint)rd, imm_j);
 		cpu_set (rd, pc);
 		pc += imm_j - 4;
 		break;
 	case 0b1100111: // jalr rd, rs1, iimm
 		switch (funct3) {
 		case 0b000:
-			log ("jalr x%u, x%u, %lld", (uint)rd, (uint)rs1, imm_i);
+			log ("jalr x%u, x%u, %"PRId64, (uint)rd, (uint)rs1, imm_i);
 			cpu_set (rd, pc);
 			pc = cpu_get (rs1);
 			break;
@@ -225,7 +226,7 @@ void cpu_exec (u32 instr)
 		default:
 			goto ud;
 		}
-		log ("%s x%u, x%u, %lld", name, (uint)rd, (uint)rs1, (i64)imm_i);
+		log ("%s x%u, x%u, %"PRId64, name, (uint)rd, (uint)rs1, (i64)imm_i);
 		cpu_set (rd, c);
 		break;
 	case 0b0011011: // aluiw rd, rs1, iimm
@@ -264,7 +265,7 @@ void cpu_exec (u32 instr)
 		}
 		c &= 0x00000000ffffffff;
 		c = extend (c);
-		log ("%s x%u, x%u, %lld", name, (uint)rd, (uint)rs1, (i64)imm_i);
+		log ("%s x%u, x%u, %"PRId64, name, (uint)rd, (uint)rs1, (i64)imm_i);
 		cpu_set (rd, c);
 		break;
 	case 0b0110011: // alu rd, rs1, rs2
@@ -366,11 +367,11 @@ void cpu_exec (u32 instr)
 		cpu_set (rd, extend ((i32)a));
 		break;
 	case 0b0001111: // fence/fence.tso/pause
-		eprintf ("%08llx: efence\n", pc - 4);
+		eprintf ("%08"PRIx64": efence\n", pc - 4);
 		break;
 	case 0b1110011: // ecall/ebreak
 		if ((instr >> 20) & 1) {
-			eprintf ("%08llx: ebreak\n", pc - 4);
+			eprintf ("%08"PRIx64": ebreak\n", pc - 4);
 			__asm __volatile__ ("int $3");
 		} else {
 			ecall ();
@@ -378,7 +379,7 @@ void cpu_exec (u32 instr)
 		break;
 	default:
 	ud:
-		errx (1, "%08llx: invalid instruction: %08x", pc - 4, instr);
+		errx (1, "%08"PRIx64": invalid instruction: %08x", pc - 4, instr);
 	}
 }
 
blob - 3173eb8aa553d0d1a0823d7a2ca83dc1da138995
blob + 30acdf6f2f674d5b82c35047169180ac73b2d2c3
--- src/ecall.c
+++ src/ecall.c
@@ -8,6 +8,7 @@
 #include <sys/msg.h>
 #include <sys/sem.h>
 #include <sys/uio.h>
+#include <inttypes.h>
 #include <signal.h>
 #include <unistd.h>
 #include <string.h>
@@ -141,7 +142,7 @@ static u64 my_brk (u64 new)
 	size_t ps;
 	void *ptr;
 
-	eprintf ("brk(%llx, %llx);", new, brkval);
+	eprintf ("brk(%"PRIx64", %"PRIx64");", new, brkval);
 
 	if (new < brkval)
 		return brkval;
@@ -214,7 +215,7 @@ void ecall (void)
 
 
 	eprintf (
-			"ecall a7=%llu, a0=%llu, a1=%llu, a2=%llu, a3=%llu, a4=%llu, a5=%llu",
+			"ecall a7=%"PRIu64", a0=%"PRIu64", a1=%"PRIu64", a2=%"PRIu64", a3=%"PRIu64", a4=%"PRIu64", a5=%"PRIu64,
 			a7, a0, a1, a2, a3, a4, a5
 	);
 
@@ -1008,11 +1009,11 @@ void ecall (void)
 		ret = enosys ("getmainvars");
 		break;
 	case SYS_debug:
-		fprintf (stderr, "DEBUG: %llu\n", a0);
+		fprintf (stderr, "DEBUG: %"PRIu64"\n", a0);
 		ret = 0;
 		break;
 	default:
-		warnx ("%08llx: unimplemented syscall %llu", pc - 4, a7);
+		warnx ("%08"PRIx64": unimplemented syscall %"PRIu64, pc - 4, a7);
 		ret = -map_errno (ENOSYS);
 		break;
 	}