arch/hexagon/kernel/process.c
Source file repositories/reference/linux-study-clean/arch/hexagon/kernel/process.c
File Facts
- System
- Linux kernel
- Corpus path
arch/hexagon/kernel/process.c- Extension
.c- Size
- 4777 bytes
- Lines
- 184
- Domain
- Architecture Layer
- Bucket
- arch/hexagon
- Inferred role
- Architecture Layer: implementation source
- Status
- source 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 uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/cpu.hlinux/sched.hlinux/sched/debug.hlinux/sched/task.hlinux/sched/task_stack.hlinux/types.hlinux/module.hlinux/tick.hlinux/uaccess.hlinux/slab.hlinux/resume_user_mode.h
Detected Declarations
function Copyrightfunction arch_cpu_idlefunction copy_threadfunction flush_threadfunction do_work_pending
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* Process creation support for Hexagon
*
* Copyright (c) 2010-2012, The Linux Foundation. All rights reserved.
*/
#include <linux/cpu.h>
#include <linux/sched.h>
#include <linux/sched/debug.h>
#include <linux/sched/task.h>
#include <linux/sched/task_stack.h>
#include <linux/types.h>
#include <linux/module.h>
#include <linux/tick.h>
#include <linux/uaccess.h>
#include <linux/slab.h>
#include <linux/resume_user_mode.h>
/*
* Program thread launch. Often defined as a macro in processor.h,
* but we're shooting for a small footprint and it's not an inner-loop
* performance-critical operation.
*
* The Hexagon ABI specifies that R28 is zero'ed before program launch,
* so that gets automatically done here. If we ever stop doing that here,
* we'll probably want to define the ELF_PLAT_INIT macro.
*/
void start_thread(struct pt_regs *regs, unsigned long pc, unsigned long sp)
{
/* We want to zero all data-containing registers. Is this overkill? */
memset(regs, 0, sizeof(*regs));
/* We might want to also zero all Processor registers here */
pt_set_usermode(regs);
pt_set_elr(regs, pc);
pt_set_rte_sp(regs, sp);
}
/*
* Spin, or better still, do a hardware or VM wait instruction
* If hardware or VM offer wait termination even though interrupts
* are disabled.
*/
void arch_cpu_idle(void)
{
__vmwait();
/* interrupts wake us up, but irqs are still disabled */
}
/*
* Copy architecture-specific thread state
*/
int copy_thread(struct task_struct *p, const struct kernel_clone_args *args)
{
u64 clone_flags = args->flags;
unsigned long usp = args->stack;
unsigned long tls = args->tls;
struct thread_info *ti = task_thread_info(p);
struct hexagon_switch_stack *ss;
struct pt_regs *childregs;
asmlinkage void ret_from_fork(void);
childregs = (struct pt_regs *) (((unsigned long) ti + THREAD_SIZE) -
sizeof(*childregs));
ti->regs = childregs;
/*
* Establish kernel stack pointer and initial PC for new thread
* Note that unlike the usual situation, we do not copy the
* parent's callee-saved here; those are in pt_regs and whatever
* we leave here will be overridden on return to userland.
*/
ss = (struct hexagon_switch_stack *) ((unsigned long) childregs -
sizeof(*ss));
ss->lr = (unsigned long)ret_from_fork;
p->thread.switch_sp = ss;
if (unlikely(args->fn)) {
memset(childregs, 0, sizeof(struct pt_regs));
/* r24 <- fn, r25 <- arg */
ss->r24 = (unsigned long)args->fn;
ss->r25 = (unsigned long)args->fn_arg;
pt_set_kmode(childregs);
return 0;
}
memcpy(childregs, current_pt_regs(), sizeof(*childregs));
ss->r2524 = 0;
if (usp)
pt_set_rte_sp(childregs, usp);
Annotation
- Immediate include surface: `linux/cpu.h`, `linux/sched.h`, `linux/sched/debug.h`, `linux/sched/task.h`, `linux/sched/task_stack.h`, `linux/types.h`, `linux/module.h`, `linux/tick.h`.
- Detected declarations: `function Copyright`, `function arch_cpu_idle`, `function copy_thread`, `function flush_thread`, `function do_work_pending`.
- Atlas domain: Architecture Layer / arch/hexagon.
- Implementation status: source 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.