1c47f10baSMichal Simek /*
2627cef44SMichal Simek * Copyright (C) 2007-2009 Michal Simek <monstr@monstr.eu>
3c47f10baSMichal Simek * Copyright (C) 2007-2009 PetaLogix
4c47f10baSMichal Simek * Copyright (C) 2006 Atmark Techno, Inc.
5c47f10baSMichal Simek *
6c47f10baSMichal Simek * This file is subject to the terms and conditions of the GNU General Public
7c47f10baSMichal Simek * License. See the file "COPYING" in the main directory of this archive
8c47f10baSMichal Simek * for more details.
9c47f10baSMichal Simek */
10c47f10baSMichal Simek
11c47f10baSMichal Simek #include <linux/init.h>
12c47f10baSMichal Simek #include <linux/stddef.h>
13c47f10baSMichal Simek #include <linux/sched.h>
14c47f10baSMichal Simek #include <linux/kernel_stat.h>
15c47f10baSMichal Simek #include <linux/ptrace.h>
16c47f10baSMichal Simek #include <linux/hardirq.h>
17c47f10baSMichal Simek #include <linux/thread_info.h>
18c47f10baSMichal Simek #include <linux/kbuild.h>
1943f2a6e8SMichal Simek #include <asm/cpuinfo.h>
20c47f10baSMichal Simek
main(int argc,char * argv[])21c47f10baSMichal Simek int main(int argc, char *argv[])
22c47f10baSMichal Simek {
23c47f10baSMichal Simek /* struct pt_regs */
24c47f10baSMichal Simek DEFINE(PT_SIZE, sizeof(struct pt_regs));
25c47f10baSMichal Simek DEFINE(PT_MSR, offsetof(struct pt_regs, msr));
26c47f10baSMichal Simek DEFINE(PT_EAR, offsetof(struct pt_regs, ear));
27c47f10baSMichal Simek DEFINE(PT_ESR, offsetof(struct pt_regs, esr));
28c47f10baSMichal Simek DEFINE(PT_FSR, offsetof(struct pt_regs, fsr));
29c47f10baSMichal Simek DEFINE(PT_PC, offsetof(struct pt_regs, pc));
30c47f10baSMichal Simek DEFINE(PT_R0, offsetof(struct pt_regs, r0));
31c47f10baSMichal Simek DEFINE(PT_R1, offsetof(struct pt_regs, r1));
32c47f10baSMichal Simek DEFINE(PT_R2, offsetof(struct pt_regs, r2));
33c47f10baSMichal Simek DEFINE(PT_R3, offsetof(struct pt_regs, r3));
34c47f10baSMichal Simek DEFINE(PT_R4, offsetof(struct pt_regs, r4));
35c47f10baSMichal Simek DEFINE(PT_R5, offsetof(struct pt_regs, r5));
36c47f10baSMichal Simek DEFINE(PT_R6, offsetof(struct pt_regs, r6));
37c47f10baSMichal Simek DEFINE(PT_R7, offsetof(struct pt_regs, r7));
38c47f10baSMichal Simek DEFINE(PT_R8, offsetof(struct pt_regs, r8));
39c47f10baSMichal Simek DEFINE(PT_R9, offsetof(struct pt_regs, r9));
40c47f10baSMichal Simek DEFINE(PT_R10, offsetof(struct pt_regs, r10));
41c47f10baSMichal Simek DEFINE(PT_R11, offsetof(struct pt_regs, r11));
42c47f10baSMichal Simek DEFINE(PT_R12, offsetof(struct pt_regs, r12));
43c47f10baSMichal Simek DEFINE(PT_R13, offsetof(struct pt_regs, r13));
44c47f10baSMichal Simek DEFINE(PT_R14, offsetof(struct pt_regs, r14));
45c47f10baSMichal Simek DEFINE(PT_R15, offsetof(struct pt_regs, r15));
46c47f10baSMichal Simek DEFINE(PT_R16, offsetof(struct pt_regs, r16));
47c47f10baSMichal Simek DEFINE(PT_R17, offsetof(struct pt_regs, r17));
48c47f10baSMichal Simek DEFINE(PT_R18, offsetof(struct pt_regs, r18));
49c47f10baSMichal Simek DEFINE(PT_R19, offsetof(struct pt_regs, r19));
50c47f10baSMichal Simek DEFINE(PT_R20, offsetof(struct pt_regs, r20));
51c47f10baSMichal Simek DEFINE(PT_R21, offsetof(struct pt_regs, r21));
52c47f10baSMichal Simek DEFINE(PT_R22, offsetof(struct pt_regs, r22));
53c47f10baSMichal Simek DEFINE(PT_R23, offsetof(struct pt_regs, r23));
54c47f10baSMichal Simek DEFINE(PT_R24, offsetof(struct pt_regs, r24));
55c47f10baSMichal Simek DEFINE(PT_R25, offsetof(struct pt_regs, r25));
56c47f10baSMichal Simek DEFINE(PT_R26, offsetof(struct pt_regs, r26));
57c47f10baSMichal Simek DEFINE(PT_R27, offsetof(struct pt_regs, r27));
58c47f10baSMichal Simek DEFINE(PT_R28, offsetof(struct pt_regs, r28));
59c47f10baSMichal Simek DEFINE(PT_R29, offsetof(struct pt_regs, r29));
60c47f10baSMichal Simek DEFINE(PT_R30, offsetof(struct pt_regs, r30));
61c47f10baSMichal Simek DEFINE(PT_R31, offsetof(struct pt_regs, r31));
62ac3efab5SMichal Simek DEFINE(PT_MODE, offsetof(struct pt_regs, pt_mode));
63c47f10baSMichal Simek BLANK();
64c47f10baSMichal Simek
65c47f10baSMichal Simek /* Magic offsets for PTRACE PEEK/POKE etc */
66c47f10baSMichal Simek DEFINE(PT_TEXT_ADDR, sizeof(struct pt_regs) + 1);
67c47f10baSMichal Simek DEFINE(PT_TEXT_LEN, sizeof(struct pt_regs) + 2);
68c47f10baSMichal Simek DEFINE(PT_DATA_ADDR, sizeof(struct pt_regs) + 3);
69c47f10baSMichal Simek BLANK();
70c47f10baSMichal Simek
71c47f10baSMichal Simek /* struct task_struct */
72c47f10baSMichal Simek DEFINE(TS_THREAD_INFO, offsetof(struct task_struct, stack));
73627cef44SMichal Simek DEFINE(TASK_FLAGS, offsetof(struct task_struct, flags));
74627cef44SMichal Simek DEFINE(TASK_PTRACE, offsetof(struct task_struct, ptrace));
75627cef44SMichal Simek DEFINE(TASK_BLOCKED, offsetof(struct task_struct, blocked));
76627cef44SMichal Simek DEFINE(TASK_MM, offsetof(struct task_struct, mm));
77627cef44SMichal Simek DEFINE(TASK_ACTIVE_MM, offsetof(struct task_struct, active_mm));
78627cef44SMichal Simek DEFINE(TASK_PID, offsetof(struct task_struct, pid));
79627cef44SMichal Simek DEFINE(TASK_THREAD, offsetof(struct task_struct, thread));
80627cef44SMichal Simek DEFINE(THREAD_KSP, offsetof(struct thread_struct, ksp));
81627cef44SMichal Simek BLANK();
82627cef44SMichal Simek
83627cef44SMichal Simek DEFINE(PGDIR, offsetof(struct thread_struct, pgdir));
84627cef44SMichal Simek BLANK();
85c47f10baSMichal Simek
86c47f10baSMichal Simek /* struct thread_info */
87c47f10baSMichal Simek DEFINE(TI_TASK, offsetof(struct thread_info, task));
88c47f10baSMichal Simek DEFINE(TI_FLAGS, offsetof(struct thread_info, flags));
89c47f10baSMichal Simek DEFINE(TI_CPU_CONTEXT, offsetof(struct thread_info, cpu_context));
9077753790SMichal Simek DEFINE(TI_PREEMPT_COUNT, offsetof(struct thread_info, preempt_count));
91c47f10baSMichal Simek BLANK();
92c47f10baSMichal Simek
93c47f10baSMichal Simek /* struct cpu_context */
94c47f10baSMichal Simek DEFINE(CC_R1, offsetof(struct cpu_context, r1)); /* r1 */
95c47f10baSMichal Simek DEFINE(CC_R2, offsetof(struct cpu_context, r2));
96c47f10baSMichal Simek /* dedicated registers */
97c47f10baSMichal Simek DEFINE(CC_R13, offsetof(struct cpu_context, r13));
98c47f10baSMichal Simek DEFINE(CC_R14, offsetof(struct cpu_context, r14));
99c47f10baSMichal Simek DEFINE(CC_R15, offsetof(struct cpu_context, r15));
100c47f10baSMichal Simek DEFINE(CC_R16, offsetof(struct cpu_context, r16));
101c47f10baSMichal Simek DEFINE(CC_R17, offsetof(struct cpu_context, r17));
102c47f10baSMichal Simek DEFINE(CC_R18, offsetof(struct cpu_context, r18));
103c47f10baSMichal Simek /* non-volatile registers */
104c47f10baSMichal Simek DEFINE(CC_R19, offsetof(struct cpu_context, r19));
105c47f10baSMichal Simek DEFINE(CC_R20, offsetof(struct cpu_context, r20));
106c47f10baSMichal Simek DEFINE(CC_R21, offsetof(struct cpu_context, r21));
107c47f10baSMichal Simek DEFINE(CC_R22, offsetof(struct cpu_context, r22));
108c47f10baSMichal Simek DEFINE(CC_R23, offsetof(struct cpu_context, r23));
109c47f10baSMichal Simek DEFINE(CC_R24, offsetof(struct cpu_context, r24));
110c47f10baSMichal Simek DEFINE(CC_R25, offsetof(struct cpu_context, r25));
111c47f10baSMichal Simek DEFINE(CC_R26, offsetof(struct cpu_context, r26));
112c47f10baSMichal Simek DEFINE(CC_R27, offsetof(struct cpu_context, r27));
113c47f10baSMichal Simek DEFINE(CC_R28, offsetof(struct cpu_context, r28));
114c47f10baSMichal Simek DEFINE(CC_R29, offsetof(struct cpu_context, r29));
115c47f10baSMichal Simek DEFINE(CC_R30, offsetof(struct cpu_context, r30));
116c47f10baSMichal Simek /* special purpose registers */
117c47f10baSMichal Simek DEFINE(CC_MSR, offsetof(struct cpu_context, msr));
118c47f10baSMichal Simek DEFINE(CC_EAR, offsetof(struct cpu_context, ear));
119c47f10baSMichal Simek DEFINE(CC_ESR, offsetof(struct cpu_context, esr));
120c47f10baSMichal Simek DEFINE(CC_FSR, offsetof(struct cpu_context, fsr));
121c47f10baSMichal Simek BLANK();
122c47f10baSMichal Simek
123*88707ebeSAppana Durga Kedareswara rao /* struct cpuinfo */
124*88707ebeSAppana Durga Kedareswara rao DEFINE(CI_DCS, offsetof(struct cpuinfo, dcache_size));
125*88707ebeSAppana Durga Kedareswara rao DEFINE(CI_DCL, offsetof(struct cpuinfo, dcache_line_length));
126*88707ebeSAppana Durga Kedareswara rao DEFINE(CI_ICS, offsetof(struct cpuinfo, icache_size));
127*88707ebeSAppana Durga Kedareswara rao DEFINE(CI_ICL, offsetof(struct cpuinfo, icache_line_length));
128*88707ebeSAppana Durga Kedareswara rao BLANK();
129*88707ebeSAppana Durga Kedareswara rao
130c47f10baSMichal Simek return 0;
131c47f10baSMichal Simek }
132