2 * This program is used to generate definitions needed by
3 * assembly language modules.
5 * We use the technique used in the OSF Mach kernel code:
6 * generate asm statements containing #defines,
7 * compile this file to assembler, and then extract the
8 * #defines from the assembly-language output.
11 #include <linux/stddef.h>
12 #include <linux/sched.h>
13 #include <linux/kernel_stat.h>
14 #include <linux/ptrace.h>
15 #include <asm/bootinfo.h>
17 #include <asm/hardirq.h>
20 #define DEFINE(sym, val) \
21 asm volatile("\n->" #sym " %0 " #val : : "i" (val))
23 #define BLANK() asm volatile("\n->" : : )
28 /* offsets into the task struct */
29 DEFINE(TASK_STATE
, offsetof(struct task_struct
, state
));
30 DEFINE(TASK_FLAGS
, offsetof(struct task_struct
, flags
));
31 DEFINE(TASK_PTRACE
, offsetof(struct task_struct
, ptrace
));
32 DEFINE(TASK_BLOCKED
, offsetof(struct task_struct
, blocked
));
33 DEFINE(TASK_THREAD
, offsetof(struct task_struct
, thread
));
34 DEFINE(TASK_THREAD_INFO
, offsetof(struct task_struct
, thread_info
));
35 DEFINE(TASK_MM
, offsetof(struct task_struct
, mm
));
36 DEFINE(TASK_ACTIVE_MM
, offsetof(struct task_struct
, active_mm
));
38 /* offsets into the kernel_stat struct */
39 DEFINE(STAT_IRQ
, offsetof(struct kernel_stat
, irqs
));
41 /* offsets into the irq_cpustat_t struct */
42 DEFINE(CPUSTAT_SOFTIRQ_PENDING
, offsetof(irq_cpustat_t
, __softirq_pending
));
44 /* offsets into the irq_node struct */
45 DEFINE(IRQ_HANDLER
, offsetof(struct irq_hand
, handler
));
46 DEFINE(IRQ_FLAGS
, offsetof(struct irq_hand
, flags
));
47 DEFINE(IRQ_DEV_ID
, offsetof(struct irq_hand
, dev_id
));
48 DEFINE(IRQ_DEVNAME
, offsetof(struct irq_hand
, devname
));
50 /* offsets into the thread struct */
51 DEFINE(THREAD_KSP
, offsetof(struct thread_struct
, ksp
));
52 DEFINE(THREAD_KPSR
, offsetof(struct thread_struct
, kpsr
));
53 DEFINE(THREAD_KESR
, offsetof(struct thread_struct
, kesr
));
54 DEFINE(THREAD_FLAGS
, offsetof(struct thread_struct
, flags
));
56 /* offsets into the pt_regs */
57 DEFINE(PT_ORIG_R2
, offsetof(struct pt_regs
, orig_r2
));
58 DEFINE(PT_R1
, offsetof(struct pt_regs
, r1
));
59 DEFINE(PT_R2
, offsetof(struct pt_regs
, r2
));
60 DEFINE(PT_R3
, offsetof(struct pt_regs
, r3
));
61 DEFINE(PT_R4
, offsetof(struct pt_regs
, r4
));
62 DEFINE(PT_R5
, offsetof(struct pt_regs
, r5
));
63 DEFINE(PT_R6
, offsetof(struct pt_regs
, r6
));
64 DEFINE(PT_R7
, offsetof(struct pt_regs
, r7
));
65 DEFINE(PT_R8
, offsetof(struct pt_regs
, r8
));
66 DEFINE(PT_R9
, offsetof(struct pt_regs
, r9
));
67 DEFINE(PT_R10
, offsetof(struct pt_regs
, r10
));
68 DEFINE(PT_R11
, offsetof(struct pt_regs
, r11
));
69 DEFINE(PT_R12
, offsetof(struct pt_regs
, r12
));
70 DEFINE(PT_R13
, offsetof(struct pt_regs
, r13
));
71 DEFINE(PT_R14
, offsetof(struct pt_regs
, r14
));
72 DEFINE(PT_R15
, offsetof(struct pt_regs
, r15
));
73 DEFINE(PT_EA
, offsetof(struct pt_regs
, ea
));
74 DEFINE(PT_RA
, offsetof(struct pt_regs
, ra
));
75 DEFINE(PT_FP
, offsetof(struct pt_regs
, fp
));
76 DEFINE(PT_SP
, offsetof(struct pt_regs
, sp
));
77 DEFINE(PT_GP
, offsetof(struct pt_regs
, gp
));
78 DEFINE(PT_ESTATUS
, offsetof(struct pt_regs
, estatus
));
79 DEFINE(PT_STATUS_EXTENSION
, offsetof(struct pt_regs
, status_extension
));
80 DEFINE(PT_REGS_SIZE
, sizeof(struct pt_regs
));
82 /* offsets into the switch_stack */
83 DEFINE(SW_R16
, offsetof(struct switch_stack
, r16
));
84 DEFINE(SW_R17
, offsetof(struct switch_stack
, r17
));
85 DEFINE(SW_R18
, offsetof(struct switch_stack
, r18
));
86 DEFINE(SW_R19
, offsetof(struct switch_stack
, r19
));
87 DEFINE(SW_R20
, offsetof(struct switch_stack
, r20
));
88 DEFINE(SW_R21
, offsetof(struct switch_stack
, r21
));
89 DEFINE(SW_R22
, offsetof(struct switch_stack
, r22
));
90 DEFINE(SW_R23
, offsetof(struct switch_stack
, r23
));
91 DEFINE(SW_FP
, offsetof(struct switch_stack
, fp
));
92 DEFINE(SW_GP
, offsetof(struct switch_stack
, gp
));
93 DEFINE(SW_RA
, offsetof(struct switch_stack
, ra
));
94 DEFINE(SWITCH_STACK_SIZE
, sizeof(struct switch_stack
));
96 DEFINE(PS_S_ASM
, PS_S
);
98 DEFINE(NIOS2_STATUS_PIE_MSK_ASM
, NIOS2_STATUS_PIE_MSK
);
99 DEFINE(NIOS2_STATUS_PIE_OFST_ASM
, NIOS2_STATUS_PIE_OFST
);
100 DEFINE(NIOS2_STATUS_U_MSK_ASM
, NIOS2_STATUS_U_MSK
);
101 DEFINE(NIOS2_STATUS_U_OFST_ASM
, NIOS2_STATUS_U_OFST
);
103 /* offsets into the kernel_stat struct */
104 DEFINE(STAT_IRQ
, offsetof(struct kernel_stat
, irqs
));
106 /* Offsets in thread_info structure, used in assembly code */
107 DEFINE(TI_TASK
, offsetof(struct thread_info
, task
));
108 DEFINE(TI_EXECDOMAIN
, offsetof(struct thread_info
, exec_domain
));
109 DEFINE(TI_FLAGS
, offsetof(struct thread_info
, flags
));
110 DEFINE(TI_CPU
, offsetof(struct thread_info
, cpu
));
111 DEFINE(TI_PREEMPT_COUNT
, offsetof(struct thread_info
, preempt_count
));
113 DEFINE(PREEMPT_ACTIVE_ASM
, PREEMPT_ACTIVE
);
115 DEFINE(THREAD_SIZE_ASM
, THREAD_SIZE
);
117 DEFINE(TIF_SYSCALL_TRACE_ASM
, TIF_SYSCALL_TRACE
);
118 DEFINE(TIF_NOTIFY_RESUME_ASM
, TIF_NOTIFY_RESUME
);
119 DEFINE(TIF_SIGPENDING_ASM
, TIF_SIGPENDING
);
120 DEFINE(TIF_NEED_RESCHED_ASM
, TIF_NEED_RESCHED
);
121 DEFINE(TIF_POLLING_NRFLAG_ASM
, TIF_POLLING_NRFLAG
);
123 DEFINE(_TIF_SYSCALL_TRACE_ASM
, _TIF_SYSCALL_TRACE
);
124 DEFINE(_TIF_NOTIFY_RESUME_ASM
, _TIF_NOTIFY_RESUME
);
125 DEFINE(_TIF_SIGPENDING_ASM
, _TIF_SIGPENDING
);
126 DEFINE(_TIF_NEED_RESCHED_ASM
, _TIF_NEED_RESCHED
);
127 DEFINE(_TIF_POLLING_NRFLAG_ASM
, _TIF_POLLING_NRFLAG
);
129 DEFINE(_TIF_WORK_MASK_ASM
, _TIF_WORK_MASK
);
131 #if defined(na_flash_kernel) && defined(na_flash_kernel_end)
133 DEFINE(NIOS_FLASH_START
, na_flash_kernel
);
134 DEFINE(NIOS_FLASH_END
, na_flash_kernel_end
);
136 /* the kernel placement in the flash*/
137 DEFINE(KERNEL_FLASH_START
, na_flash_kernel
);
138 DEFINE(KERNEL_FLASH_LEN
, 0x200000);
140 /* the romdisk placement in the flash */
141 DEFINE(LINUX_ROMFS_START
, na_flash_kernel
+0x200000);
142 DEFINE(LINUX_ROMFS_END
, na_flash_kernel_end
);
144 #error Sorry,you dont have na_flash_kernel or na_flash_kernel_end defined in the core.
147 #if defined(nasys_program_mem) && defined(nasys_program_mem_end)
149 DEFINE(LINUX_SDRAM_START
, nasys_program_mem
);
150 DEFINE(LINUX_SDRAM_END
, nasys_program_mem_end
);
152 #error Sorry,you dont have nasys_program_mem or nasys_program_mem_end defined in the core.
155 DEFINE(NIOS2_ICACHE_SIZE
, nasys_icache_size
);
156 DEFINE(NIOS2_ICACHE_LINE_SIZE
, nasys_icache_line_size
);
157 DEFINE(NIOS2_DCACHE_SIZE
, nasys_dcache_size
);
158 DEFINE(NIOS2_DCACHE_LINE_SIZE
, nasys_dcache_line_size
);
161 DEFINE(NA_ENET_ASM
, na_enet
);
164 #if defined(na_enet_reset)
165 DEFINE(NA_ENET_RESET_ASM
, na_enet_reset
);
168 #if defined(na_enet_reset_n)
169 DEFINE(NA_ENET_RESET_N_ASM
, na_enet_reset_n
);
172 #if defined(na_ide_interface)
173 DEFINE(NA_IDE_INTERFACE_ASM
, na_ide_interface
);
176 #if defined(na_timer0)
177 DEFINE(NA_TIMER0_ASM
, na_timer0
);
178 DEFINE(NP_TIMERCONTROL_ASM
, offsetof(np_timer
, np_timercontrol
));
179 DEFINE(NP_TIMERSTATUS_ASM
, offsetof(np_timer
, np_timerstatus
));
182 #if defined(na_uart0)
183 DEFINE(NA_UART0_ASM
, na_uart0
);
184 DEFINE(NP_UARTCONTROL_ASM
, offsetof(np_uart
, np_uartcontrol
));
185 DEFINE(NP_UARTSTATUS_ASM
, offsetof(np_uart
, np_uartstatus
));
188 #if defined(na_uart1)
189 DEFINE(NA_UART1_ASM
, na_uart1
);
192 #if defined(na_uart2)
193 DEFINE(NA_UART2_ASM
, na_uart2
);
196 #if defined(na_uart3)
197 DEFINE(NA_UART3_ASM
, na_uart3
);