mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-04-27 10:46:24 +00:00
tests: mips_kseg0_1.c prints out friendly error message rather than just error code
This commit is contained in:
parent
7553c9c1c2
commit
cea1cf210d
|
@ -3,7 +3,8 @@
|
|||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
//Test for the MIPS kseg0 and kseg1 memory segments
|
||||
// Test for the MIPS kseg0 and kseg1 memory segments.
|
||||
// See issue https://github.com/unicorn-engine/unicorn/issues/217
|
||||
// The kseg0 address range 0x80000000-0x9FFFFFFF is not mapped through the MMU,
|
||||
// but instead is directly translated to low ram by masking off the high address bit.
|
||||
// Similarly, the address range kseg1 0xA00000000-0xBFFFFFF is translated directly to
|
||||
|
@ -26,49 +27,43 @@ int main()
|
|||
uc_err err;
|
||||
|
||||
err = uc_open(UC_ARCH_MIPS, UC_MODE_MIPS32, &uc);
|
||||
if (err)
|
||||
{
|
||||
if (err) {
|
||||
printf("uc_open %d\n", err);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// map 4Kb memory for this emulation, into the real address space
|
||||
err = uc_mem_map(uc, KSEG0_1_REAL_ADDRESS, 4 * 1024, UC_PROT_ALL);
|
||||
if (err)
|
||||
{
|
||||
if (err) {
|
||||
printf("uc_mem_map %d\n", err);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// write machine code to be emulated to memory
|
||||
err = uc_mem_write(uc, KSEG0_1_REAL_ADDRESS, MIPS_CODE_EL, sizeof(MIPS_CODE_EL) - 1);
|
||||
if (err)
|
||||
{
|
||||
printf("uc_mem_map %d\n", err);
|
||||
if (err) {
|
||||
printf("uc_mem_map %s\n", uc_strerror(err));
|
||||
return 1;
|
||||
}
|
||||
|
||||
//Start emulation at real address, this currently succeeds
|
||||
err = uc_emu_start(uc, KSEG0_1_REAL_ADDRESS, KSEG0_1_REAL_ADDRESS + 4, 0, 0);
|
||||
if (err)
|
||||
{
|
||||
printf("uc_emu_start at real address: %d\n", err);
|
||||
if (err) {
|
||||
printf("uc_emu_start at real address: %s\n", uc_strerror(err));
|
||||
return 1;
|
||||
}
|
||||
|
||||
//Start emulation at virtual address in kseg0, this cuurently fails
|
||||
err = uc_emu_start(uc, KSEG0_VIRT_ADDRESS, KSEG0_VIRT_ADDRESS + 4, 0, 0);
|
||||
if (err)
|
||||
{
|
||||
printf("uc_emu_start at kseg0 address: %d\n", err);
|
||||
if (err) {
|
||||
printf("uc_emu_start at kseg0 address: %s\n", uc_strerror(err));
|
||||
return 1;
|
||||
}
|
||||
|
||||
//Start emulation at virtual address in kseg1, this currently fails
|
||||
err = uc_emu_start(uc, KSEG1_VIRT_ADDRESS, KSEG1_VIRT_ADDRESS + 4, 0, 0);
|
||||
if (err)
|
||||
{
|
||||
printf("uc_emu_start at kseg1 address: %d\n", err);
|
||||
if (err) {
|
||||
printf("uc_emu_start at kseg1 address: %s\n", uc_strerror(err));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue