1/*
2 * generate definitions needed by assembly language modules
3 *
4 * Copyright 2004-2009 Analog Devices Inc.
5 *
6 * Licensed under the GPL-2 or later
7 */
8
9#include <linux/stddef.h>
10#include <linux/sched.h>
11#include <linux/kernel_stat.h>
12#include <linux/ptrace.h>
13#include <linux/hardirq.h>
14#include <linux/irq.h>
15#include <linux/thread_info.h>
16#include <linux/kbuild.h>
17#include <asm/pda.h>
18
19int main(void)
20{
21	/* offsets into the task struct */
22	DEFINE(TASK_STATE, offsetof(struct task_struct, state));
23	DEFINE(TASK_FLAGS, offsetof(struct task_struct, flags));
24	DEFINE(TASK_PTRACE, offsetof(struct task_struct, ptrace));
25	DEFINE(TASK_BLOCKED, offsetof(struct task_struct, blocked));
26	DEFINE(TASK_THREAD, offsetof(struct task_struct, thread));
27	DEFINE(TASK_THREAD_INFO, offsetof(struct task_struct, stack));
28	DEFINE(TASK_MM, offsetof(struct task_struct, mm));
29	DEFINE(TASK_ACTIVE_MM, offsetof(struct task_struct, active_mm));
30	DEFINE(TASK_SIGPENDING, offsetof(struct task_struct, pending));
31
32	/* offsets into the irq_cpustat_t struct */
33	DEFINE(CPUSTAT_SOFTIRQ_PENDING,
34	       offsetof(irq_cpustat_t, __softirq_pending));
35
36	/* offsets into the thread struct */
37	DEFINE(THREAD_KSP, offsetof(struct thread_struct, ksp));
38	DEFINE(THREAD_USP, offsetof(struct thread_struct, usp));
39	DEFINE(THREAD_SR, offsetof(struct thread_struct, seqstat));
40	DEFINE(PT_SR, offsetof(struct thread_struct, seqstat));
41	DEFINE(THREAD_ESP0, offsetof(struct thread_struct, esp0));
42	DEFINE(THREAD_PC, offsetof(struct thread_struct, pc));
43	DEFINE(KERNEL_STACK_SIZE, THREAD_SIZE);
44
45	/* offsets in thread_info struct */
46	OFFSET(TI_TASK, thread_info, task);
47	OFFSET(TI_FLAGS, thread_info, flags);
48	OFFSET(TI_CPU, thread_info, cpu);
49	OFFSET(TI_PREEMPT, thread_info, preempt_count);
50
51	/* offsets into the pt_regs */
52	DEFINE(PT_ORIG_R0, offsetof(struct pt_regs, orig_r0));
53	DEFINE(PT_ORIG_P0, offsetof(struct pt_regs, orig_p0));
54	DEFINE(PT_ORIG_PC, offsetof(struct pt_regs, orig_pc));
55	DEFINE(PT_R0, offsetof(struct pt_regs, r0));
56	DEFINE(PT_R1, offsetof(struct pt_regs, r1));
57	DEFINE(PT_R2, offsetof(struct pt_regs, r2));
58	DEFINE(PT_R3, offsetof(struct pt_regs, r3));
59	DEFINE(PT_R4, offsetof(struct pt_regs, r4));
60	DEFINE(PT_R5, offsetof(struct pt_regs, r5));
61	DEFINE(PT_R6, offsetof(struct pt_regs, r6));
62	DEFINE(PT_R7, offsetof(struct pt_regs, r7));
63
64	DEFINE(PT_P0, offsetof(struct pt_regs, p0));
65	DEFINE(PT_P1, offsetof(struct pt_regs, p1));
66	DEFINE(PT_P2, offsetof(struct pt_regs, p2));
67	DEFINE(PT_P3, offsetof(struct pt_regs, p3));
68	DEFINE(PT_P4, offsetof(struct pt_regs, p4));
69	DEFINE(PT_P5, offsetof(struct pt_regs, p5));
70
71	DEFINE(PT_FP, offsetof(struct pt_regs, fp));
72	DEFINE(PT_USP, offsetof(struct pt_regs, usp));
73	DEFINE(PT_I0, offsetof(struct pt_regs, i0));
74	DEFINE(PT_I1, offsetof(struct pt_regs, i1));
75	DEFINE(PT_I2, offsetof(struct pt_regs, i2));
76	DEFINE(PT_I3, offsetof(struct pt_regs, i3));
77	DEFINE(PT_M0, offsetof(struct pt_regs, m0));
78	DEFINE(PT_M1, offsetof(struct pt_regs, m1));
79	DEFINE(PT_M2, offsetof(struct pt_regs, m2));
80	DEFINE(PT_M3, offsetof(struct pt_regs, m3));
81	DEFINE(PT_L0, offsetof(struct pt_regs, l0));
82	DEFINE(PT_L1, offsetof(struct pt_regs, l1));
83	DEFINE(PT_L2, offsetof(struct pt_regs, l2));
84	DEFINE(PT_L3, offsetof(struct pt_regs, l3));
85	DEFINE(PT_B0, offsetof(struct pt_regs, b0));
86	DEFINE(PT_B1, offsetof(struct pt_regs, b1));
87	DEFINE(PT_B2, offsetof(struct pt_regs, b2));
88	DEFINE(PT_B3, offsetof(struct pt_regs, b3));
89	DEFINE(PT_A0X, offsetof(struct pt_regs, a0x));
90	DEFINE(PT_A0W, offsetof(struct pt_regs, a0w));
91	DEFINE(PT_A1X, offsetof(struct pt_regs, a1x));
92	DEFINE(PT_A1W, offsetof(struct pt_regs, a1w));
93	DEFINE(PT_LC0, offsetof(struct pt_regs, lc0));
94	DEFINE(PT_LC1, offsetof(struct pt_regs, lc1));
95	DEFINE(PT_LT0, offsetof(struct pt_regs, lt0));
96	DEFINE(PT_LT1, offsetof(struct pt_regs, lt1));
97	DEFINE(PT_LB0, offsetof(struct pt_regs, lb0));
98	DEFINE(PT_LB1, offsetof(struct pt_regs, lb1));
99	DEFINE(PT_ASTAT, offsetof(struct pt_regs, astat));
100	DEFINE(PT_RESERVED, offsetof(struct pt_regs, reserved));
101	DEFINE(PT_RETS, offsetof(struct pt_regs, rets));
102	DEFINE(PT_PC, offsetof(struct pt_regs, pc));
103	DEFINE(PT_RETX, offsetof(struct pt_regs, retx));
104	DEFINE(PT_RETN, offsetof(struct pt_regs, retn));
105	DEFINE(PT_RETE, offsetof(struct pt_regs, rete));
106	DEFINE(PT_SEQSTAT, offsetof(struct pt_regs, seqstat));
107	DEFINE(PT_SYSCFG, offsetof(struct pt_regs, syscfg));
108	DEFINE(PT_IPEND, offsetof(struct pt_regs, ipend));
109	DEFINE(SIZEOF_PTREGS, sizeof(struct pt_regs));
110	DEFINE(PT_TEXT_ADDR, sizeof(struct pt_regs));        /* Needed by gdb */
111	DEFINE(PT_TEXT_END_ADDR, 4 + sizeof(struct pt_regs));/* Needed by gdb */
112	DEFINE(PT_DATA_ADDR, 8 + sizeof(struct pt_regs));    /* Needed by gdb */
113	DEFINE(PT_FDPIC_EXEC, 12 + sizeof(struct pt_regs));  /* Needed by gdb */
114	DEFINE(PT_FDPIC_INTERP, 16 + sizeof(struct pt_regs));/* Needed by gdb */
115
116	/* signal defines */
117	DEFINE(SIGSEGV, SIGSEGV);
118	DEFINE(SIGTRAP, SIGTRAP);
119
120	/* PDA management (in L1 scratchpad) */
121	DEFINE(PDA_SYSCFG, offsetof(struct blackfin_pda, syscfg));
122#ifdef CONFIG_SMP
123	DEFINE(PDA_IRQFLAGS, offsetof(struct blackfin_pda, imask));
124#endif
125	DEFINE(PDA_IPDT, offsetof(struct blackfin_pda, ipdt));
126	DEFINE(PDA_IPDT_SWAPCOUNT, offsetof(struct blackfin_pda, ipdt_swapcount));
127	DEFINE(PDA_DPDT, offsetof(struct blackfin_pda, dpdt));
128	DEFINE(PDA_DPDT_SWAPCOUNT, offsetof(struct blackfin_pda, dpdt_swapcount));
129	DEFINE(PDA_EXIPTR, offsetof(struct blackfin_pda, ex_iptr));
130	DEFINE(PDA_EXOPTR, offsetof(struct blackfin_pda, ex_optr));
131	DEFINE(PDA_EXBUF, offsetof(struct blackfin_pda, ex_buf));
132	DEFINE(PDA_EXIMASK, offsetof(struct blackfin_pda, ex_imask));
133	DEFINE(PDA_EXSTACK, offsetof(struct blackfin_pda, ex_stack));
134	DEFINE(PDA_EXIPEND, offsetof(struct blackfin_pda, ex_ipend));
135#ifdef ANOMALY_05000261
136	DEFINE(PDA_LFRETX, offsetof(struct blackfin_pda, last_cplb_fault_retx));
137#endif
138	DEFINE(PDA_DCPLB, offsetof(struct blackfin_pda, dcplb_fault_addr));
139	DEFINE(PDA_ICPLB, offsetof(struct blackfin_pda, icplb_fault_addr));
140	DEFINE(PDA_RETX, offsetof(struct blackfin_pda, retx));
141	DEFINE(PDA_SEQSTAT, offsetof(struct blackfin_pda, seqstat));
142#ifdef CONFIG_DEBUG_DOUBLEFAULT
143	DEFINE(PDA_DF_DCPLB, offsetof(struct blackfin_pda, dcplb_doublefault_addr));
144	DEFINE(PDA_DF_ICPLB, offsetof(struct blackfin_pda, icplb_doublefault_addr));
145	DEFINE(PDA_DF_SEQSTAT, offsetof(struct blackfin_pda, seqstat_doublefault));
146	DEFINE(PDA_DF_RETX, offsetof(struct blackfin_pda, retx_doublefault));
147#endif
148
149	/* PDA initial management */
150	DEFINE(PDA_INIT_RETX, offsetof(struct blackfin_initial_pda, retx));
151#ifdef CONFIG_DEBUG_DOUBLEFAULT
152	DEFINE(PDA_INIT_DF_DCPLB, offsetof(struct blackfin_initial_pda, dcplb_doublefault_addr));
153	DEFINE(PDA_INIT_DF_ICPLB, offsetof(struct blackfin_initial_pda, icplb_doublefault_addr));
154	DEFINE(PDA_INIT_DF_SEQSTAT, offsetof(struct blackfin_initial_pda, seqstat_doublefault));
155	DEFINE(PDA_INIT_DF_RETX, offsetof(struct blackfin_initial_pda, retx_doublefault));
156#endif
157
158#ifdef CONFIG_SMP
159	/* Inter-core lock (in L2 SRAM) */
160	DEFINE(SIZEOF_CORELOCK, sizeof(struct corelock_slot));
161#endif
162
163	return 0;
164}
165