xref: /openbmc/linux/arch/csky/kernel/asm-offsets.c (revision e3d786a3)
1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
3 
4 #include <linux/sched.h>
5 #include <linux/kernel_stat.h>
6 #include <linux/kbuild.h>
7 #include <abi/regdef.h>
8 
9 int main(void)
10 {
11 	/* offsets into the task struct */
12 	DEFINE(TASK_STATE,        offsetof(struct task_struct, state));
13 	DEFINE(TASK_THREAD_INFO,  offsetof(struct task_struct, stack));
14 	DEFINE(TASK_FLAGS,        offsetof(struct task_struct, flags));
15 	DEFINE(TASK_PTRACE,       offsetof(struct task_struct, ptrace));
16 	DEFINE(TASK_THREAD,       offsetof(struct task_struct, thread));
17 	DEFINE(TASK_MM,           offsetof(struct task_struct, mm));
18 	DEFINE(TASK_ACTIVE_MM,    offsetof(struct task_struct, active_mm));
19 
20 	/* offsets into the thread struct */
21 	DEFINE(THREAD_KSP,        offsetof(struct thread_struct, ksp));
22 	DEFINE(THREAD_SR,         offsetof(struct thread_struct, sr));
23 	DEFINE(THREAD_ESP0,       offsetof(struct thread_struct, esp0));
24 	DEFINE(THREAD_FESR,       offsetof(struct thread_struct, user_fp.fesr));
25 	DEFINE(THREAD_FCR,        offsetof(struct thread_struct, user_fp.fcr));
26 	DEFINE(THREAD_FPREG,      offsetof(struct thread_struct, user_fp.vr));
27 	DEFINE(THREAD_DSPHI,      offsetof(struct thread_struct, hi));
28 	DEFINE(THREAD_DSPLO,      offsetof(struct thread_struct, lo));
29 
30 	/* offsets into the thread_info struct */
31 	DEFINE(TINFO_FLAGS,       offsetof(struct thread_info, flags));
32 	DEFINE(TINFO_PREEMPT,     offsetof(struct thread_info, preempt_count));
33 	DEFINE(TINFO_ADDR_LIMIT,  offsetof(struct thread_info, addr_limit));
34 	DEFINE(TINFO_TP_VALUE,   offsetof(struct thread_info, tp_value));
35 	DEFINE(TINFO_TASK,        offsetof(struct thread_info, task));
36 
37 	/* offsets into the pt_regs */
38 	DEFINE(PT_PC,             offsetof(struct pt_regs, pc));
39 	DEFINE(PT_ORIG_AO,        offsetof(struct pt_regs, orig_a0));
40 	DEFINE(PT_SR,             offsetof(struct pt_regs, sr));
41 
42 	DEFINE(PT_A0,             offsetof(struct pt_regs, a0));
43 	DEFINE(PT_A1,             offsetof(struct pt_regs, a1));
44 	DEFINE(PT_A2,             offsetof(struct pt_regs, a2));
45 	DEFINE(PT_A3,             offsetof(struct pt_regs, a3));
46 	DEFINE(PT_REGS0,          offsetof(struct pt_regs, regs[0]));
47 	DEFINE(PT_REGS1,          offsetof(struct pt_regs, regs[1]));
48 	DEFINE(PT_REGS2,          offsetof(struct pt_regs, regs[2]));
49 	DEFINE(PT_REGS3,          offsetof(struct pt_regs, regs[3]));
50 	DEFINE(PT_REGS4,          offsetof(struct pt_regs, regs[4]));
51 	DEFINE(PT_REGS5,          offsetof(struct pt_regs, regs[5]));
52 	DEFINE(PT_REGS6,          offsetof(struct pt_regs, regs[6]));
53 	DEFINE(PT_REGS7,          offsetof(struct pt_regs, regs[7]));
54 	DEFINE(PT_REGS8,          offsetof(struct pt_regs, regs[8]));
55 	DEFINE(PT_REGS9,          offsetof(struct pt_regs, regs[9]));
56 	DEFINE(PT_R15,            offsetof(struct pt_regs, lr));
57 #if defined(__CSKYABIV2__)
58 	DEFINE(PT_R16,            offsetof(struct pt_regs, exregs[0]));
59 	DEFINE(PT_R17,            offsetof(struct pt_regs, exregs[1]));
60 	DEFINE(PT_R18,            offsetof(struct pt_regs, exregs[2]));
61 	DEFINE(PT_R19,            offsetof(struct pt_regs, exregs[3]));
62 	DEFINE(PT_R20,            offsetof(struct pt_regs, exregs[4]));
63 	DEFINE(PT_R21,            offsetof(struct pt_regs, exregs[5]));
64 	DEFINE(PT_R22,            offsetof(struct pt_regs, exregs[6]));
65 	DEFINE(PT_R23,            offsetof(struct pt_regs, exregs[7]));
66 	DEFINE(PT_R24,            offsetof(struct pt_regs, exregs[8]));
67 	DEFINE(PT_R25,            offsetof(struct pt_regs, exregs[9]));
68 	DEFINE(PT_R26,            offsetof(struct pt_regs, exregs[10]));
69 	DEFINE(PT_R27,            offsetof(struct pt_regs, exregs[11]));
70 	DEFINE(PT_R28,            offsetof(struct pt_regs, exregs[12]));
71 	DEFINE(PT_R29,            offsetof(struct pt_regs, exregs[13]));
72 	DEFINE(PT_R30,            offsetof(struct pt_regs, exregs[14]));
73 	DEFINE(PT_R31,            offsetof(struct pt_regs, exregs[15]));
74 	DEFINE(PT_RHI,            offsetof(struct pt_regs, rhi));
75 	DEFINE(PT_RLO,            offsetof(struct pt_regs, rlo));
76 #endif
77 	DEFINE(PT_USP,            offsetof(struct pt_regs, usp));
78 
79 	/* offsets into the irq_cpustat_t struct */
80 	DEFINE(CPUSTAT_SOFTIRQ_PENDING, offsetof(irq_cpustat_t,
81 						__softirq_pending));
82 
83 	/* signal defines */
84 	DEFINE(SIGSEGV, SIGSEGV);
85 	DEFINE(SIGTRAP, SIGTRAP);
86 
87 	return 0;
88 }
89