|
AquilaOS documentation
How it works, and its code
|
#include <cpu/cpu.h>Go to the source code of this file.
Data Structures | |
| struct | aarch64_ctx |
| Where a thread goes on in the kernel when it runs again: the registers that a function call keeps (AAPCS64: x19 to x29, and the link register), and the stack pointer. More... | |
| struct | aarch64_thread |
| A thread's aarch64 state (thread->arch). More... | |
Macros | |
| #define | FPSIMD_STATE_SIZE 528 |
| #define | USER_STACK (0x0000800000000000UL) |
| #define | USER_STACK_BASE (USER_STACK - USER_STACK_SIZE) |
| #define | SIGCODE_ADDR (USER_STACK_BASE - 0x1000) |
| #define | KERN_STACK_SIZE (16384U) |
Functions | |
| int | aarch64_ctx_save (struct aarch64_ctx *ctx) |
| void | aarch64_ctx_load (struct aarch64_ctx *ctx) |
| void | aarch64_fpsimd_switch (struct thread *thread) |
| Gets the registers ready for a thread that is about to run: its use of them traps, unless the registers already hold its values. | |
| int | aarch64_fpsimd_trap (void) |
| Handles the trap of user mode's use of the registers: they get the running thread's values, and its use stops trapping. | |
| void * | aarch64_fpsimd_current (struct thread *thread) |
| Returns a thread's FP/SIMD state as it is now, saving it from the registers first if they hold it. | |
| void | aarch64_fpsimd_drop (struct thread *thread) |
| Throws away a thread's FP/SIMD state, when it goes or execs a new program, and the registers' values if they're the thread's. | |
| int | aarch64_fpsimd_fork (struct thread *parent, struct aarch64_thread *child) |
| Gives a child of fork() a copy of its parent's FP/SIMD state, if the parent has one. | |
| void | aarch64_fpsimd_restore (struct thread *thread, const void *state) |
| Gives a thread back the FP/SIMD state that a signal frame kept, for sigreturn(). | |
| static void | arch_interrupts_enable (void) |
| Unmasks IRQs (DAIF.I). | |
| static void | arch_interrupts_disable (void) |
| Masks IRQs. | |
| void | aarch64_jump_user (uintptr_t pc, uintptr_t sp, uintptr_t x0, uintptr_t x1, uintptr_t x2, uintptr_t kstack) |
| void | aarch64_goto (uintptr_t fn, uintptr_t sp) |
| void | aarch64_return_to_user (struct aarch64_regs *r, int syscall) |
| Takes the current thread's signals on its way back to user mode, and restarts or fails the system call that a signal interrupted. | |
| void | arch_syscall (struct aarch64_regs *r) |
| #define FPSIMD_STATE_SIZE 528 |
Definition at line 44 of file arch.h.
Referenced by aarch64_fpsimd_fork(), aarch64_fpsimd_restore(), aarch64_fpsimd_trap(), and deliver().
| #define KERN_STACK_SIZE (16384U) |
Definition at line 68 of file arch.h.
Referenced by aarch64_thread_new(), arch_kthread_create(), arch_proc_fork(), arch_proc_init(), and arch_thread_create().
| #define SIGCODE_ADDR (USER_STACK_BASE - 0x1000) |
Definition at line 65 of file arch.h.
Referenced by arch_sigcode_map(), deliver(), and deliver().
| #define USER_STACK (0x0000800000000000UL) |
Definition at line 60 of file arch.h.
Referenced by abort(), arch_proc_init(), exec_stack_build(), isr_dispatch(), and pmap_remove_all().
| #define USER_STACK_BASE (USER_STACK - USER_STACK_SIZE) |
Definition at line 61 of file arch.h.
Referenced by binfmt_elf_load_segments(), binfmt_fmt_load(), and sys_sbrk().
| void aarch64_ctx_load | ( | struct aarch64_ctx * | ctx | ) |
References aarch64_ctx_load().
Referenced by aarch64_ctx_load(), and arch_thread_switch().
| int aarch64_ctx_save | ( | struct aarch64_ctx * | ctx | ) |
References aarch64_ctx_save().
Referenced by aarch64_ctx_save(), aarch64_preempt(), and arch_sleep().
| void * aarch64_fpsimd_current | ( | struct thread * | thread | ) |
Returns a thread's FP/SIMD state as it is now, saving it from the registers first if they hold it.
| thread | the thread |
Definition at line 64 of file fpsimd.c.
References aarch64_fpsimd_current(), aarch64_fpsimd_save(), thread::arch, fp_thread, and aarch64_thread::fpsimd.
Referenced by aarch64_fpsimd_current(), aarch64_fpsimd_fork(), and deliver().
| void aarch64_fpsimd_drop | ( | struct thread * | thread | ) |
Throws away a thread's FP/SIMD state, when it goes or execs a new program, and the registers' values if they're the thread's.
| thread | the thread |
Definition at line 106 of file fpsimd.c.
References aarch64_fpsimd_drop(), thread::arch, CPACR_FPEN_EL0_TRAP, fp_thread, fpen(), aarch64_thread::fpsimd, kfree(), and NULL.
Referenced by aarch64_fpsimd_drop(), arch_exec_start(), and arch_thread_kill().
| int aarch64_fpsimd_fork | ( | struct thread * | parent, |
| struct aarch64_thread * | child ) |
Gives a child of fork() a copy of its parent's FP/SIMD state, if the parent has one.
| parent | the thread that forked |
| child | the child's aarch64 state |
Definition at line 129 of file fpsimd.c.
References aarch64_fpsimd_current(), aarch64_fpsimd_fork(), aarch64_thread::fpsimd, FPSIMD_STATE_SIZE, kmalloc(), and memcpy().
Referenced by aarch64_fpsimd_fork(), and arch_proc_fork().
| void aarch64_fpsimd_restore | ( | struct thread * | thread, |
| const void * | state ) |
Gives a thread back the FP/SIMD state that a signal frame kept, for sigreturn().
The registers are loaded with it at their next use.
| thread | the thread |
| state | the state the frame kept, or NULL if it had none (the registers are then zeros) |
Definition at line 151 of file fpsimd.c.
References aarch64_fpsimd_restore(), thread::arch, CPACR_FPEN_EL0_TRAP, fp_thread, fpen(), aarch64_thread::fpsimd, FPSIMD_STATE_SIZE, memcpy(), memset(), and NULL.
Referenced by aarch64_fpsimd_restore(), and arch_sigreturn().
| void aarch64_fpsimd_switch | ( | struct thread * | thread | ) |
Gets the registers ready for a thread that is about to run: its use of them traps, unless the registers already hold its values.
| thread | the thread about to run, or NULL |
Definition at line 52 of file fpsimd.c.
References aarch64_fpsimd_switch(), CPACR_FPEN_EL0_TRAP, CPACR_FPEN_NONE, fp_thread, and fpen().
Referenced by aarch64_fpsimd_switch(), arch_thread_spawn(), and arch_thread_switch().
| int aarch64_fpsimd_trap | ( | void | ) |
Handles the trap of user mode's use of the registers: they get the running thread's values, and its use stops trapping.
Definition at line 80 of file fpsimd.c.
References aarch64_fpsimd_load(), aarch64_fpsimd_save(), aarch64_fpsimd_trap(), thread::arch, CPACR_FPEN_NONE, curthread, fp_thread, fpen(), aarch64_thread::fpsimd, FPSIMD_STATE_SIZE, kmalloc(), and M_ZERO.
Referenced by aarch64_fpsimd_trap(), and sync_dispatch().
References aarch64_goto(), aarch64_return_to_user(), and arch_syscall().
Referenced by aarch64_goto(), arch_cur_thread_kill(), arch_idle(), and arch_thread_spawn().
| void aarch64_jump_user | ( | uintptr_t | pc, |
| uintptr_t | sp, | ||
| uintptr_t | x0, | ||
| uintptr_t | x1, | ||
| uintptr_t | x2, | ||
| uintptr_t | kstack ) |
References aarch64_jump_user().
Referenced by aarch64_jump_user(), and thread_spawn().
| void aarch64_return_to_user | ( | struct aarch64_regs * | r, |
| int | syscall ) |
Takes the current thread's signals on its way back to user mode, and restarts or fails the system call that a signal interrupted.
| r | the user context saved on the kernel stack |
| syscall | whether the thread is returning from a system call |
Definition at line 201 of file signal.c.
References aarch64_return_to_user(), thread::arch, curthread, deliver(), ERESTARTNOHAND, ERESTARTSYS, aarch64_regs::orig_x0, thread::owner, aarch64_regs::pc, REGS_USER, thread::restarting, thread::sig_oldmask, thread::sig_oldmask_set, proc::sigaction, proc::sigmask, signal_take(), and aarch64_regs::x.
Referenced by aarch64_goto(), aarch64_irq(), aarch64_return_to_user(), abort(), arch_syscall(), and sync_dispatch().
|
inlinestatic |
Masks IRQs.
Definition at line 77 of file arch.h.
References arch_interrupts_disable().
Referenced by arch_halt(), arch_interrupts_disable(), and proc_kill().
|
inlinestatic |
Unmasks IRQs (DAIF.I).
The kernel runs with them masked.
Definition at line 71 of file arch.h.
References arch_interrupts_enable().
Referenced by arch_interrupts_enable().
| void arch_syscall | ( | struct aarch64_regs * | r | ) |
Definition at line 23 of file syscall.c.
References aarch64_preempt(), aarch64_return_to_user(), arch_syscall(), curthread, sched_urgent, syscall_dispatch(), and aarch64_regs::x.
Referenced by aarch64_goto(), arch_syscall(), arch_syscall(), isr_dispatch(), and sync_dispatch().