move new files out from platform support patch
[openwrt/openwrt.git] / target / linux / ubicom32 / files / arch / ubicom32 / kernel / asm-offsets.c
1 /*
2 * arch/ubicom32/kernel/asm-offsets.c
3 * Ubicom32 architecture definitions needed by assembly language modules.
4 *
5 * (C) Copyright 2009, Ubicom, Inc.
6 *
7 * This file is part of the Ubicom32 Linux Kernel Port.
8 *
9 * The Ubicom32 Linux Kernel Port is free software: you can redistribute
10 * it and/or modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation, either version 2 of the
12 * License, or (at your option) any later version.
13 *
14 * The Ubicom32 Linux Kernel Port is distributed in the hope that it
15 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
16 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
17 * the GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with the Ubicom32 Linux Kernel Port. If not,
21 * see <http://www.gnu.org/licenses/>.
22 *
23 * Ubicom32 implementation derived from (with many thanks):
24 * arch/m68knommu
25 * arch/blackfin
26 * arch/parisc
27 */
28 /*
29 * This program is used to generate definitions needed by
30 * assembly language modules.
31 *
32 * We use the technique used in the OSF Mach kernel code:
33 * generate asm statements containing #defines,
34 * compile this file to assembler, and then extract the
35 * #defines from the assembly-language output.
36 */
37
38 #include <linux/module.h>
39 #include <linux/stddef.h>
40 #include <linux/sched.h>
41 #include <linux/kernel_stat.h>
42 #include <linux/ptrace.h>
43 #include <linux/hardirq.h>
44 #include <asm/bootinfo.h>
45 #include <asm/irq.h>
46 #include <asm/thread_info.h>
47
48 #define DEFINE(sym, val) \
49 asm volatile("\n->" #sym " %0 " #val : : "i" (val))
50
51 #define BLANK() asm volatile("\n->" : : )
52
53 int main(void)
54 {
55 /* offsets into the task struct */
56 DEFINE(TASK_STATE, offsetof(struct task_struct, state));
57 DEFINE(TASK_FLAGS, offsetof(struct task_struct, flags));
58 DEFINE(TASK_PTRACE, offsetof(struct task_struct, ptrace));
59 DEFINE(TASK_BLOCKED, offsetof(struct task_struct, blocked));
60 DEFINE(TASK_THREAD, offsetof(struct task_struct, thread));
61 DEFINE(TASK_THREAD_INFO, offsetof(struct task_struct, stack));
62 DEFINE(TASK_MM, offsetof(struct task_struct, mm));
63 DEFINE(TASK_ACTIVE_MM, offsetof(struct task_struct, active_mm));
64
65 /* offsets into the kernel_stat struct */
66 // DEFINE(STAT_IRQ, offsetof(struct kernel_stat, irqs));
67
68 /* offsets into the irq_cpustat_t struct */
69 DEFINE(CPUSTAT_SOFTIRQ_PENDING, offsetof(irq_cpustat_t, __softirq_pending));
70
71 /* offsets into the thread struct */
72 DEFINE(THREAD_D10, offsetof(struct thread_struct, d10));
73 DEFINE(THREAD_D11, offsetof(struct thread_struct, d11));
74 DEFINE(THREAD_D12, offsetof(struct thread_struct, d12));
75 DEFINE(THREAD_D13, offsetof(struct thread_struct, d13));
76 DEFINE(THREAD_A1, offsetof(struct thread_struct, a1));
77 DEFINE(THREAD_A2, offsetof(struct thread_struct, a2));
78 DEFINE(THREAD_A5, offsetof(struct thread_struct, a5));
79 DEFINE(THREAD_A6, offsetof(struct thread_struct, a6));
80 DEFINE(THREAD_SP, offsetof(struct thread_struct, sp));
81
82 /* offsets into the pt_regs */
83 DEFINE(PT_D0, offsetof(struct pt_regs, dn[0]));
84 DEFINE(PT_D1, offsetof(struct pt_regs, dn[1]));
85 DEFINE(PT_D2, offsetof(struct pt_regs, dn[2]));
86 DEFINE(PT_D3, offsetof(struct pt_regs, dn[3]));
87 DEFINE(PT_D4, offsetof(struct pt_regs, dn[4]));
88 DEFINE(PT_D5, offsetof(struct pt_regs, dn[5]));
89 DEFINE(PT_D6, offsetof(struct pt_regs, dn[6]));
90 DEFINE(PT_D7, offsetof(struct pt_regs, dn[7]));
91 DEFINE(PT_D8, offsetof(struct pt_regs, dn[8]));
92 DEFINE(PT_D9, offsetof(struct pt_regs, dn[9]));
93 DEFINE(PT_D10, offsetof(struct pt_regs, dn[10]));
94 DEFINE(PT_D11, offsetof(struct pt_regs, dn[11]));
95 DEFINE(PT_D12, offsetof(struct pt_regs, dn[12]));
96 DEFINE(PT_D13, offsetof(struct pt_regs, dn[13]));
97 DEFINE(PT_D14, offsetof(struct pt_regs, dn[14]));
98 DEFINE(PT_D15, offsetof(struct pt_regs, dn[15]));
99 DEFINE(PT_A0, offsetof(struct pt_regs, an[0]));
100 DEFINE(PT_A1, offsetof(struct pt_regs, an[1]));
101 DEFINE(PT_A2, offsetof(struct pt_regs, an[2]));
102 DEFINE(PT_A3, offsetof(struct pt_regs, an[3]));
103 DEFINE(PT_A4, offsetof(struct pt_regs, an[4]));
104 DEFINE(PT_A5, offsetof(struct pt_regs, an[5]));
105 DEFINE(PT_A6, offsetof(struct pt_regs, an[6]));
106 DEFINE(PT_A7, offsetof(struct pt_regs, an[7]));
107 DEFINE(PT_SP, offsetof(struct pt_regs, an[7]));
108
109 DEFINE(PT_ACC0HI, offsetof(struct pt_regs, acc0[0]));
110 DEFINE(PT_ACC0LO, offsetof(struct pt_regs, acc0[1]));
111 DEFINE(PT_MAC_RC16, offsetof(struct pt_regs, mac_rc16));
112
113 DEFINE(PT_ACC1HI, offsetof(struct pt_regs, acc1[0]));
114 DEFINE(PT_ACC1LO, offsetof(struct pt_regs, acc1[1]));
115
116 DEFINE(PT_SOURCE3, offsetof(struct pt_regs, source3));
117 DEFINE(PT_INST_CNT, offsetof(struct pt_regs, inst_cnt));
118 DEFINE(PT_CSR, offsetof(struct pt_regs, csr));
119 DEFINE(PT_DUMMY_UNUSED, offsetof(struct pt_regs, dummy_unused));
120
121 DEFINE(PT_INT_MASK0, offsetof(struct pt_regs, int_mask0));
122 DEFINE(PT_INT_MASK1, offsetof(struct pt_regs, int_mask1));
123
124 DEFINE(PT_PC, offsetof(struct pt_regs, pc));
125
126 DEFINE(PT_TRAP_CAUSE, offsetof(struct pt_regs, trap_cause));
127
128 DEFINE(PT_SIZE, sizeof(struct pt_regs));
129
130 DEFINE(PT_FRAME_TYPE, offsetof(struct pt_regs, frame_type));
131
132 DEFINE(PT_ORIGINAL_D0, offsetof(struct pt_regs, original_dn_0));
133 DEFINE(PT_PREVIOUS_PC, offsetof(struct pt_regs, previous_pc));
134
135 /* offsets into the kernel_stat struct */
136 // DEFINE(STAT_IRQ, offsetof(struct kernel_stat, irqs));
137
138 /* signal defines */
139 DEFINE(SIGSEGV, SIGSEGV);
140 //DEFINE(SEGV_MAPERR, SEGV_MAPERR);
141 DEFINE(SIGTRAP, SIGTRAP);
142 //DEFINE(TRAP_TRACE, TRAP_TRACE);
143
144 DEFINE(PT_PTRACED, PT_PTRACED);
145 DEFINE(PT_DTRACE, PT_DTRACE);
146
147 DEFINE(ASM_THREAD_SIZE, THREAD_SIZE);
148
149 /* Offsets in thread_info structure */
150 DEFINE(TI_TASK, offsetof(struct thread_info, task));
151 DEFINE(TI_EXECDOMAIN, offsetof(struct thread_info, exec_domain));
152 DEFINE(TI_FLAGS, offsetof(struct thread_info, flags));
153 DEFINE(TI_PREEMPTCOUNT, offsetof(struct thread_info, preempt_count));
154 DEFINE(TI_CPU, offsetof(struct thread_info, cpu));
155 DEFINE(TI_INTR_NESTING, offsetof(struct thread_info, interrupt_nesting));
156 DEFINE(ASM_TIF_NEED_RESCHED, TIF_NEED_RESCHED);
157 DEFINE(ASM_TIF_SYSCALL_TRACE, TIF_SYSCALL_TRACE);
158 DEFINE(ASM_TIF_SIGPENDING, TIF_SIGPENDING);
159
160 return 0;
161 }