2 * arch/ubicom32/kernel/asm-offsets.c
3 * Ubicom32 architecture definitions needed by assembly language modules.
5 * (C) Copyright 2009, Ubicom, Inc.
7 * This file is part of the Ubicom32 Linux Kernel Port.
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.
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.
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/>.
23 * Ubicom32 implementation derived from (with many thanks):
29 * This program is used to generate definitions needed by
30 * assembly language modules.
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.
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>
46 #include <asm/thread_info.h>
48 #define DEFINE(sym, val) \
49 asm volatile("\n->" #sym " %0 " #val : : "i" (val))
51 #define BLANK() asm volatile("\n->" : : )
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
));
65 /* offsets into the kernel_stat struct */
66 // DEFINE(STAT_IRQ, offsetof(struct kernel_stat, irqs));
68 /* offsets into the irq_cpustat_t struct */
69 DEFINE(CPUSTAT_SOFTIRQ_PENDING
, offsetof(irq_cpustat_t
, __softirq_pending
));
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
));
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]));
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
));
113 DEFINE(PT_ACC1HI
, offsetof(struct pt_regs
, acc1
[0]));
114 DEFINE(PT_ACC1LO
, offsetof(struct pt_regs
, acc1
[1]));
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
));
121 DEFINE(PT_INT_MASK0
, offsetof(struct pt_regs
, int_mask0
));
122 DEFINE(PT_INT_MASK1
, offsetof(struct pt_regs
, int_mask1
));
124 DEFINE(PT_PC
, offsetof(struct pt_regs
, pc
));
126 DEFINE(PT_TRAP_CAUSE
, offsetof(struct pt_regs
, trap_cause
));
128 DEFINE(PT_SIZE
, sizeof(struct pt_regs
));
130 DEFINE(PT_FRAME_TYPE
, offsetof(struct pt_regs
, frame_type
));
132 DEFINE(PT_ORIGINAL_D0
, offsetof(struct pt_regs
, original_dn_0
));
133 DEFINE(PT_PREVIOUS_PC
, offsetof(struct pt_regs
, previous_pc
));
135 /* offsets into the kernel_stat struct */
136 // DEFINE(STAT_IRQ, offsetof(struct kernel_stat, irqs));
139 DEFINE(SIGSEGV
, SIGSEGV
);
140 //DEFINE(SEGV_MAPERR, SEGV_MAPERR);
141 DEFINE(SIGTRAP
, SIGTRAP
);
142 //DEFINE(TRAP_TRACE, TRAP_TRACE);
144 DEFINE(PT_PTRACED
, PT_PTRACED
);
145 DEFINE(PT_DTRACE
, PT_DTRACE
);
147 DEFINE(ASM_THREAD_SIZE
, THREAD_SIZE
);
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
);