aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/kernel/process.c
diff options
context:
space:
mode:
authorFranck Bui-Huu <vagabon.xyz@gmail.com>2006-08-03 03:29:15 -0400
committerRalf Baechle <ralf@linux-mips.org>2006-09-27 08:37:24 -0400
commitc0efbb6dc2726785482d85a284c883d541a6e0be (patch)
tree786a13988605f27fc38d1f11ab555c361cc96a92 /arch/mips/kernel/process.c
parentdf586d59a4f069bb60a94ff4e5b64fe5c876f72c (diff)
[MIPS] Make get_frame_info() more readable.
Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp> Signed-off-by: Franck Bui-Huu <vagabon.xyz@gmail.com> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/kernel/process.c')
-rw-r--r--arch/mips/kernel/process.c67
1 files changed, 36 insertions, 31 deletions
diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
index 8709a46a45c1..93d5432759db 100644
--- a/arch/mips/kernel/process.c
+++ b/arch/mips/kernel/process.c
@@ -281,48 +281,53 @@ static struct mips_frame_info {
281} *schedule_frame, mfinfo[64]; 281} *schedule_frame, mfinfo[64];
282static int mfinfo_num; 282static int mfinfo_num;
283 283
284static inline int is_ra_save_ins(union mips_instruction *ip)
285{
286 /* sw / sd $ra, offset($sp) */
287 return (ip->i_format.opcode == sw_op || ip->i_format.opcode == sd_op) &&
288 ip->i_format.rs == 29 &&
289 ip->i_format.rt == 31;
290}
291
292static inline int is_jal_jalr_jr_ins(union mips_instruction *ip)
293{
294 if (ip->j_format.opcode == jal_op)
295 return 1;
296 if (ip->r_format.opcode != spec_op)
297 return 0;
298 return ip->r_format.func == jalr_op || ip->r_format.func == jr_op;
299}
300
301static inline int is_sp_move_ins(union mips_instruction *ip)
302{
303 /* addiu/daddiu sp,sp,-imm */
304 if (ip->i_format.rs != 29 || ip->i_format.rt != 29)
305 return 0;
306 if (ip->i_format.opcode == addiu_op || ip->i_format.opcode == daddiu_op)
307 return 1;
308 return 0;
309}
310
284static int get_frame_info(struct mips_frame_info *info) 311static int get_frame_info(struct mips_frame_info *info)
285{ 312{
286 int i; 313 union mips_instruction *ip = info->func;
287 void *func = info->func; 314 int i, max_insns =
288 union mips_instruction *ip = (union mips_instruction *)func; 315 min(128UL, info->func_size / sizeof(union mips_instruction));
316
289 info->pc_offset = -1; 317 info->pc_offset = -1;
290 info->frame_size = 0; 318 info->frame_size = 0;
291 for (i = 0; i < 128; i++, ip++) {
292 /* if jal, jalr, jr, stop. */
293 if (ip->j_format.opcode == jal_op ||
294 (ip->r_format.opcode == spec_op &&
295 (ip->r_format.func == jalr_op ||
296 ip->r_format.func == jr_op)))
297 break;
298 319
299 if (info->func_size && i >= info->func_size / 4) 320 for (i = 0; i < max_insns; i++, ip++) {
321
322 if (is_jal_jalr_jr_ins(ip))
300 break; 323 break;
301 if ( 324 if (is_sp_move_ins(ip)) {
302#ifdef CONFIG_32BIT
303 ip->i_format.opcode == addiu_op &&
304#endif
305#ifdef CONFIG_64BIT
306 ip->i_format.opcode == daddiu_op &&
307#endif
308 ip->i_format.rs == 29 &&
309 ip->i_format.rt == 29) {
310 /* addiu/daddiu sp,sp,-imm */
311 if (info->frame_size) 325 if (info->frame_size)
312 continue; 326 continue;
313 info->frame_size = - ip->i_format.simmediate; 327 info->frame_size = - ip->i_format.simmediate;
314 } 328 }
315 329
316 if ( 330 if (is_ra_save_ins(ip)) {
317#ifdef CONFIG_32BIT
318 ip->i_format.opcode == sw_op &&
319#endif
320#ifdef CONFIG_64BIT
321 ip->i_format.opcode == sd_op &&
322#endif
323 ip->i_format.rs == 29 &&
324 ip->i_format.rt == 31) {
325 /* sw / sd $ra, offset($sp) */
326 if (info->pc_offset != -1) 331 if (info->pc_offset != -1)
327 continue; 332 continue;
328 info->pc_offset = 333 info->pc_offset =