Added messages for privileged instructions
This commit is contained in:
		@@ -96,6 +96,13 @@
 | 
				
			|||||||
#define FUNC3_ECALL_EBREAK 0x0
 | 
					#define FUNC3_ECALL_EBREAK 0x0
 | 
				
			||||||
#define IMM_ECALL 0x0
 | 
					#define IMM_ECALL 0x0
 | 
				
			||||||
#define IMM_EBREAK 0x1
 | 
					#define IMM_EBREAK 0x1
 | 
				
			||||||
 | 
					/* RISC-V Privileged Instructions */
 | 
				
			||||||
 | 
					#define FUNC7_SFENCEVMA 0x9
 | 
				
			||||||
 | 
					#define FUNC7_WFI 0x8
 | 
				
			||||||
 | 
					#define FUNC7_SINVALVMA 0x11
 | 
				
			||||||
 | 
					#define FUNC7_SFENCEWINVAL_SFENCEINVALIR 0xC
 | 
				
			||||||
 | 
					#define IMM5_SFENCEWINVAL 0x0
 | 
				
			||||||
 | 
					#define IMM5_SFENCEINVALIR 0x1
 | 
				
			||||||
/* RISC-V RV32 ZICSR Extension */
 | 
					/* RISC-V RV32 ZICSR Extension */
 | 
				
			||||||
#define FUNC3_CSRRW 0x1
 | 
					#define FUNC3_CSRRW 0x1
 | 
				
			||||||
#define FUNC3_CSRRS 0x2
 | 
					#define FUNC3_CSRRS 0x2
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -517,12 +517,23 @@ static void cpu_execute(rv32_cpu_t* cpu, instruction_t* instruction)
 | 
				
			|||||||
							cpu->sim_ticks_left = 1;
 | 
												cpu->sim_ticks_left = 1;
 | 
				
			||||||
							cpu->pc -= 4;
 | 
												cpu->pc -= 4;
 | 
				
			||||||
							break;
 | 
												break;
 | 
				
			||||||
 | 
											default:
 | 
				
			||||||
 | 
												switch(instruction->func7)
 | 
				
			||||||
 | 
												{
 | 
				
			||||||
 | 
													case FUNC7_SFENCEVMA:
 | 
				
			||||||
 | 
														fprintf(stderr, "SFENCE.VMA: Guest kernel must think we have an MMU. We have none.\n");
 | 
				
			||||||
 | 
														break;
 | 
				
			||||||
 | 
													case FUNC7_WFI:
 | 
				
			||||||
 | 
														fprintf(stderr, "WFI: Guest kernel must think we have interrupts. We have none.\n");
 | 
				
			||||||
 | 
														break;
 | 
				
			||||||
								default:
 | 
													default:
 | 
				
			||||||
									fprintf(stderr, "FATAL: Unknown IMM for ECALL/EBREAK instruction while executing (IMM=0x%x)\n", instruction->immediate);
 | 
														fprintf(stderr, "FATAL: Unknown IMM for ECALL/EBREAK instruction while executing (IMM=0x%x)\n", instruction->immediate);
 | 
				
			||||||
									exit(EXIT_FAILURE);
 | 
														exit(EXIT_FAILURE);
 | 
				
			||||||
									break;
 | 
														break;
 | 
				
			||||||
							}
 | 
												}
 | 
				
			||||||
							break;
 | 
												break;
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
										break;
 | 
				
			||||||
				case FUNC3_CSRRW:
 | 
									case FUNC3_CSRRW:
 | 
				
			||||||
					fprintf(stderr, "CSRRW\n");
 | 
										fprintf(stderr, "CSRRW\n");
 | 
				
			||||||
					break;
 | 
										break;
 | 
				
			||||||
@@ -1052,11 +1063,39 @@ static void cpu_print_instruction(instruction_t* instruction)
 | 
				
			|||||||
						case IMM_EBREAK:
 | 
											case IMM_EBREAK:
 | 
				
			||||||
							printf("ebreak\n");
 | 
												printf("ebreak\n");
 | 
				
			||||||
							break;
 | 
												break;
 | 
				
			||||||
 | 
											default:
 | 
				
			||||||
 | 
												switch(instruction->func7)
 | 
				
			||||||
 | 
												{
 | 
				
			||||||
 | 
													case FUNC7_WFI:
 | 
				
			||||||
 | 
														printf("wfi\n");
 | 
				
			||||||
 | 
														break;
 | 
				
			||||||
 | 
													case FUNC7_SFENCEVMA:
 | 
				
			||||||
 | 
														printf("sfence.vma\n");
 | 
				
			||||||
 | 
														break;
 | 
				
			||||||
 | 
													case FUNC7_SINVALVMA:
 | 
				
			||||||
 | 
														printf("sinval.vma\n");
 | 
				
			||||||
 | 
														break;
 | 
				
			||||||
 | 
													case FUNC7_SFENCEWINVAL_SFENCEINVALIR:
 | 
				
			||||||
 | 
														switch(instruction->immediate & 0x1F)
 | 
				
			||||||
 | 
														{
 | 
				
			||||||
 | 
															case IMM5_SFENCEWINVAL:
 | 
				
			||||||
 | 
																printf("sfence.w.inval\n");
 | 
				
			||||||
 | 
																break;
 | 
				
			||||||
 | 
															case IMM5_SFENCEINVALIR:
 | 
				
			||||||
 | 
																printf("sfence.inval.ir\n");
 | 
				
			||||||
 | 
																break;
 | 
				
			||||||
 | 
															default:
 | 
				
			||||||
 | 
																fprintf(stderr, "Warning: Unknown IMM for SFENCEWINVAL/SFENCEINVALIR instruction (IMM=0x%x)\n", instruction->immediate);
 | 
				
			||||||
 | 
																break;
 | 
				
			||||||
 | 
														}
 | 
				
			||||||
 | 
														break;
 | 
				
			||||||
								default:
 | 
													default:
 | 
				
			||||||
									fprintf(stderr, "Warning: Unknown IMM for ECALL/EBREAK instruction (IMM=0x%x)\n", instruction->immediate);
 | 
														fprintf(stderr, "Warning: Unknown IMM for ECALL/EBREAK instruction (IMM=0x%x)\n", instruction->immediate);
 | 
				
			||||||
									break;
 | 
														break;
 | 
				
			||||||
							}
 | 
												}
 | 
				
			||||||
							break;
 | 
												break;
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
										break;
 | 
				
			||||||
				case FUNC3_CSRRW:
 | 
									case FUNC3_CSRRW:
 | 
				
			||||||
					printf("csrrw csr[0x%x], x%u, x%u\n", instruction->immediate, instruction->rd, instruction->rs1);
 | 
										printf("csrrw csr[0x%x], x%u, x%u\n", instruction->immediate, instruction->rd, instruction->rs1);
 | 
				
			||||||
					break;
 | 
										break;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user