syscall --- To refactor `linux-user/mips/cpu_loop.c` to handle your custom syscall more effectively, you can introduce a MIPS-specific base number similar to how ARM handles it with `ARM_NR_BASE`. Here's a suggestion on how you could modify the code: 1. **Define a Base Number:** First, define a constant for the MIPS base number in your file. ```c #define MIPS_SYS_NR_BASE 4000 ``` 2. **Modify Syscall Handling Logic:** Update the logic that determines if the syscall is supported by using this base number: ```c int syscall_num = env->active_tc.gpr[2] - MIPS_SYS_NR_BASE; if (syscall_num >= sizeof(mips_syscall_args) / sizeof(struct mips_syscall_args_entry)) { ret = -TARGET_ENOSYS; } else { // Handle the syscall using mips_syscall_args[syscall_num] } ``` 3. **Ensure Proper Array Size Calculation:** When checking the size of `mips_syscall_args`, use the correct calculation to determine the number of entries: ```c sizeof(mips_syscall_args) / sizeof(struct mips_syscall_args_entry) ``` By introducing `MIPS_SYS_NR_BASE`, you make the code more maintainable and consistent with ARM's approach, which should help in correctly handling your custom syscall.