blob: d50b26da45bd1b10dccbb00d8c17bd2a808aa37d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
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.
|