arch/mips/include/asm/syscall.h
Source file repositories/reference/linux-study-clean/arch/mips/include/asm/syscall.h
File Facts
- System
- Linux kernel
- Corpus path
arch/mips/include/asm/syscall.h- Extension
.h- Size
- 4588 bytes
- Lines
- 188
- Domain
- Architecture Layer
- Bucket
- arch/mips
- Inferred role
- Architecture Layer: syscall or user/kernel boundary
- Status
- core implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Defines or participates in a user/kernel boundary; inspect argument validation, copy_from_user/copy_to_user, credentials, and dispatch target.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/compiler.huapi/linux/audit.hlinux/elf-em.hlinux/kernel.hlinux/sched.hlinux/uaccess.hasm/ptrace.hasm/unistd.h
Detected Declarations
function Copyrightfunction syscall_get_nrfunction syscall_set_nrfunction mips_syscall_update_nrfunction mips_get_syscall_argfunction mips_set_syscall_argfunction syscall_get_errorfunction syscall_get_return_valuefunction syscall_rollbackfunction syscall_get_argumentsfunction syscall_set_argumentsfunction syscall_get_arch
Annotated Snippet
#ifndef __ASM_MIPS_SYSCALL_H
#define __ASM_MIPS_SYSCALL_H
#include <linux/compiler.h>
#include <uapi/linux/audit.h>
#include <linux/elf-em.h>
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/uaccess.h>
#include <asm/ptrace.h>
#include <asm/unistd.h>
#ifndef __NR_syscall /* Only defined if _MIPS_SIM == _MIPS_SIM_ABI32 */
#define __NR_syscall 4000
#endif
static inline bool mips_syscall_is_indirect(struct task_struct *task,
struct pt_regs *regs)
{
/* O32 ABI syscall() - Either 64-bit with O32 or 32-bit */
return (IS_ENABLED(CONFIG_32BIT) ||
test_tsk_thread_flag(task, TIF_32BIT_REGS)) &&
(regs->regs[2] == __NR_syscall);
}
static inline long syscall_get_nr(struct task_struct *task,
struct pt_regs *regs)
{
return task_thread_info(task)->syscall;
}
static inline void syscall_set_nr(struct task_struct *task,
struct pt_regs *regs,
int nr)
{
/*
* New syscall number has to be assigned to regs[2] because
* it is loaded from there unconditionally after return from
* syscall_trace_enter() invocation.
*
* Consequently, if the syscall was indirect and nr != __NR_syscall,
* then after this assignment the syscall will cease to be indirect.
*/
task_thread_info(task)->syscall = regs->regs[2] = nr;
}
static inline void mips_syscall_update_nr(struct task_struct *task,
struct pt_regs *regs)
{
/*
* v0 is the system call number, except for O32 ABI syscall(), where it
* ends up in a0.
*/
if (mips_syscall_is_indirect(task, regs))
task_thread_info(task)->syscall = regs->regs[4];
else
task_thread_info(task)->syscall = regs->regs[2];
}
static inline void mips_get_syscall_arg(unsigned long *arg,
struct task_struct *task, struct pt_regs *regs, unsigned int n)
{
#ifdef CONFIG_32BIT
switch (n) {
case 0: case 1: case 2: case 3:
*arg = regs->regs[4 + n];
return;
case 4: case 5: case 6: case 7:
*arg = regs->args[n];
return;
}
#else
*arg = regs->regs[4 + n];
if ((IS_ENABLED(CONFIG_MIPS32_O32) &&
test_tsk_thread_flag(task, TIF_32BIT_REGS)))
*arg = (unsigned int)*arg;
#endif
}
static inline void mips_set_syscall_arg(unsigned long *arg,
struct task_struct *task, struct pt_regs *regs, unsigned int n)
{
#ifdef CONFIG_32BIT
switch (n) {
case 0: case 1: case 2: case 3:
regs->regs[4 + n] = *arg;
return;
case 4: case 5: case 6: case 7:
*arg = regs->args[n] = *arg;
return;
Annotation
- Immediate include surface: `linux/compiler.h`, `uapi/linux/audit.h`, `linux/elf-em.h`, `linux/kernel.h`, `linux/sched.h`, `linux/uaccess.h`, `asm/ptrace.h`, `asm/unistd.h`.
- Detected declarations: `function Copyright`, `function syscall_get_nr`, `function syscall_set_nr`, `function mips_syscall_update_nr`, `function mips_get_syscall_arg`, `function mips_set_syscall_arg`, `function syscall_get_error`, `function syscall_get_return_value`, `function syscall_rollback`, `function syscall_get_arguments`.
- Atlas domain: Architecture Layer / arch/mips.
- Implementation status: core implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.