1 /******************************************************************************
3 ** FILE NAME : ifxmips_ptm_vdsl.c
9 ** DESCRIPTION : PTM driver common source file (core functions for VR9)
10 ** COPYRIGHT : Copyright (c) 2006
11 ** Infineon Technologies AG
12 ** Am Campeon 1-12, 85579 Neubiberg, Germany
14 ** This program is free software; you can redistribute it and/or modify
15 ** it under the terms of the GNU General Public License as published by
16 ** the Free Software Foundation; either version 2 of the License, or
17 ** (at your option) any later version.
20 ** $Date $Author $Comment
21 ** 07 JUL 2009 Xu Liang Init Version
22 *******************************************************************************/
26 #ifdef CONFIG_IFX_PTM_TEST_PROC
29 * ####################################
31 * ####################################
37 #include <linux/kernel.h>
38 #include <linux/module.h>
39 #include <linux/version.h>
40 #include <linux/types.h>
41 #include <linux/errno.h>
42 #include <linux/proc_fs.h>
43 #include <linux/init.h>
44 #include <linux/ioctl.h>
45 #include <linux/etherdevice.h>
48 * Chip Specific Head File
50 #include <asm/ifx/ifx_types.h>
51 #include <asm/ifx/ifx_regs.h>
52 #include <asm/ifx/common_routines.h>
53 #include "ifxmips_ptm_common.h"
54 #include "ifxmips_ptm_ppe_common.h"
59 * ####################################
61 * ####################################
67 * ####################################
69 * ####################################
75 static inline void proc_file_create(void);
76 static inline void proc_file_delete(void);
81 static int proc_write_mem(struct file *, const char *, unsigned long, void *);
82 static int proc_read_pp32(char *, char **, off_t, int, int *, void *);
83 static int proc_write_pp32(struct file *, const char *, unsigned long, void *);
84 static int stricmp(const char *, const char *);
85 static int strincmp(const char *, const char *, int);
86 static int get_token(char **, char **, int *, int *);
87 static int get_number(char **, int *, int);
88 static inline void ignore_space(char **, int *);
93 * ####################################
95 * ####################################
101 * ####################################
103 * ####################################
106 static inline void proc_file_create(void)
108 struct proc_dir_entry *res;
110 res = create_proc_entry("driver/ifx_ptm/mem",
114 res->write_proc = proc_write_mem;
116 printk("%s:%s:%d: failed to create proc mem!", __FILE__, __func__, __LINE__);
118 res = create_proc_entry("driver/ifx_ptm/pp32",
122 res->read_proc = proc_read_pp32;
123 res->write_proc = proc_write_pp32;
126 printk("%s:%s:%d: failed to create proc pp32!", __FILE__, __func__, __LINE__);
129 static inline void proc_file_delete(void)
131 remove_proc_entry("driver/ifx_ptm/pp32", NULL);
133 remove_proc_entry("driver/ifx_ptm/mem", NULL);
136 static inline unsigned long sb_addr_to_fpi_addr_convert(unsigned long sb_addr)
138 #define PP32_SB_ADDR_END 0xFFFF
140 if ( sb_addr < PP32_SB_ADDR_END) {
141 return (unsigned long ) SB_BUFFER(sb_addr);
148 static int proc_write_mem(struct file *file, const char *buf, unsigned long count, void *data)
154 char local_buf[1024];
157 len = sizeof(local_buf) < count ? sizeof(local_buf) - 1 : count;
158 len = len - copy_from_user(local_buf, buf, len);
163 while ( get_token(&p1, &p2, &len, &colon) )
165 if ( stricmp(p1, "w") == 0 || stricmp(p1, "write") == 0 || stricmp(p1, "r") == 0 || stricmp(p1, "read") == 0 )
174 ignore_space(&p2, &len);
175 p = (unsigned long *)get_number(&p2, &len, 1);
176 p = (unsigned long *)sb_addr_to_fpi_addr_convert( (unsigned long) p);
178 if ( (u32)p >= KSEG0 )
181 ignore_space(&p2, &len);
182 if ( !len || !((*p2 >= '0' && *p2 <= '9') || (*p2 >= 'a' && *p2 <= 'f') || (*p2 >= 'A' && *p2 <= 'F')) )
185 *p++ = (u32)get_number(&p2, &len, 1);
188 else if ( *p1 == 'r' )
190 ignore_space(&p2, &len);
191 p = (unsigned long *)get_number(&p2, &len, 1);
192 p = (unsigned long *)sb_addr_to_fpi_addr_convert( (unsigned long) p);
194 if ( (u32)p >= KSEG0 )
196 ignore_space(&p2, &len);
197 n = (int)get_number(&p2, &len, 0);
206 n += (l = ((int)p >> 2) & 0x03);
207 p = (unsigned long *)((u32)p & ~0x0F);
208 for ( i = 0; i < n; i++ )
210 if ( (i & 0x03) == 0 )
212 printk("%08X:", (u32)p);
223 printk(" %08X", data);
224 for ( k = 0; k < 4; k++ )
226 c = ((char*)&data)[k];
227 pch[k] = c < ' ' ? '.' : c;
232 if ( (i & 0x03) == 0x03 )
235 printk(" ; %s\n", str);
238 if ( (n & 0x03) != 0x00 )
240 for ( k = 4 - (n & 0x03); k > 0; k-- )
243 printk(" ; %s\n", str);
254 static int proc_read_pp32(char *page, char **start, off_t off, int count, int *eof, void *data)
256 static const char *halt_stat[] = {
265 static const char *brk_src_data[] = {
275 static const char *brk_src_code[] = {
286 len += sprintf(page + off + len, "Task No %d, PC %04x\n", *PP32_DBG_TASK_NO & 0x03, *PP32_DBG_CUR_PC & 0xFFFF);
288 if ( !(*PP32_HALT_STAT & 0x01) )
289 len += sprintf(page + off + len, " Halt State: Running\n");
292 len += sprintf(page + off + len, " Halt State: Stopped");
294 for ( bit = 2, i = 0; bit <= (1 << 7); bit <<= 1, i++ )
295 if ( (*PP32_HALT_STAT & bit) )
299 len += sprintf(page + off + len, ", ");
303 len += sprintf(page + off + len, " | ");
304 len += sprintf(page + off + len, halt_stat[i]);
307 len += sprintf(page + off + len, "\n");
309 cur_task = *PP32_DBG_TASK_NO & 0x03;
310 len += sprintf(page + off + len, "General Purpose Register (Task %d):\n", cur_task);
311 for ( i = 0; i < 4; i++ )
313 for ( j = 0; j < 4; j++ )
314 len += sprintf(page + off + len, " %2d: %08x", i + j * 4, *PP32_DBG_TASK_GPR(cur_task, i + j * 4));
315 len += sprintf(page + off + len, "\n");
319 len += sprintf(page + off + len, " Break Src: data1 - %s, data0 - %s, pc3 - %s, pc2 - %s, pc1 - %s, pc0 - %s\n",
320 brk_src_data[(*PP32_BRK_SRC >> 11) & 0x07], brk_src_data[(*PP32_BRK_SRC >> 8) & 0x07], brk_src_code[(*PP32_BRK_SRC >> 3) & 0x01], brk_src_code[(*PP32_BRK_SRC >> 2) & 0x01], brk_src_code[(*PP32_BRK_SRC >> 1) & 0x01], brk_src_code[*PP32_BRK_SRC & 0x01]);
322 for ( i = 0; i < 4; i++ )
323 len += sprintf(page + off + len, " pc%d: %04x - %04x\n", i, *PP32_DBG_PC_MIN(i), *PP32_DBG_PC_MAX(i));
325 for ( i = 0; i < 2; i++ )
326 len += sprintf(page + off + len, " data%d: %04x - %04x (%08x)\n", i, *PP32_DBG_DATA_MIN(i), *PP32_DBG_DATA_MAX(i), *PP32_DBG_DATA_VAL(i));
333 static int proc_write_pp32(struct file *file, const char *buf, unsigned long count, void *data)
343 len = count < sizeof(str) ? count : sizeof(str) - 1;
344 rlen = len - copy_from_user(str, buf, len);
345 while ( rlen && str[rlen - 1] <= ' ' )
348 for ( p = str; *p && *p <= ' '; p++, rlen-- );
354 if ( stricmp(str, "start") == 0 )
355 *PP32_DBG_CTRL = DBG_CTRL_START_SET(1);
356 else if ( stricmp(str, "stop") == 0 )
357 *PP32_DBG_CTRL = DBG_CTRL_STOP_SET(1);
358 else if ( stricmp(str, "step") == 0 )
359 *PP32_DBG_CTRL = DBG_CTRL_STEP_SET(1);
360 else if ( strincmp(p, "pc", 2) == 0 && p[2] >= '0' && p[2] <= '3' && p[3] == ' ' )
362 id = (int)(p[2] - '0');
365 *PP32_BRK_SRC &= ~PP32_BRK_SRC_PC(id);
366 if ( stricmp(p, "off") != 0 )
368 ignore_space(&p, &rlen);
369 *PP32_DBG_PC_MIN(id) = *PP32_DBG_PC_MAX(id) = get_number(&p, &rlen, 1);
370 ignore_space(&p, &rlen);
373 addr = get_number(&p, &rlen, 1);
374 if ( addr >= *PP32_DBG_PC_MIN(id) )
375 *PP32_DBG_PC_MAX(id) = addr;
377 *PP32_DBG_PC_MIN(id) = addr;
379 *PP32_BRK_SRC |= PP32_BRK_SRC_PC(id);
382 else if ( strincmp(p, "daddr", 5) == 0 && p[5] >= '0' && p[5] <= '1' && p[6] == ' ' )
384 id = (int)(p[5] - '0');
387 *PP32_BRK_SRC &= ~PP32_BRK_SRC_DATA(id, 7);
388 if ( stricmp(p, "off") != 0 )
390 ignore_space(&p, &rlen);
391 *PP32_DBG_DATA_MIN(id) = *PP32_DBG_DATA_MAX(id) = get_number(&p, &rlen, 1);
393 ignore_space(&p, &rlen);
394 if ( rlen > 0 && ((*p >= '0' && *p <= '9') || (*p >= 'a' && *p <= 'f') || (*p >= 'A' && *p <= 'F')) )
396 addr = get_number(&p, &rlen, 1);
397 if ( addr >= *PP32_DBG_PC_MIN(id) )
398 *PP32_DBG_DATA_MAX(id) = addr;
400 *PP32_DBG_DATA_MIN(id) = addr;
401 ignore_space(&p, &rlen);
405 else if ( *p == 'r' && p[1] == 'w' )
415 ignore_space(&p, &rlen);
416 if ( (*p >= '0' && *p <= '9') || (*p >= 'a' && *p <= 'f') || (*p >= 'A' && *p <= 'F'))
418 *PP32_DBG_DATA_VAL(id) = get_number(&p, &rlen, 1);
422 *PP32_BRK_SRC |= PP32_BRK_SRC_DATA(id, cmd);
427 printk("echo \"<command>\" > /proc/driver/ifx_ptm/pp32\n");
428 printk(" command:\n");
429 printk(" start - run pp32\n");
430 printk(" stop - stop pp32\n");
431 printk(" step - run pp32 with one step only\n");
432 printk(" pc0 - pc0 <addr_min [addr_max]>/off, set break point PC0\n");
433 printk(" pc1 - pc1 <addr_min [addr_max]>/off, set break point PC1\n");
434 printk(" pc2 - pc2 <addr_min [addr_max]>/off, set break point PC2\n");
435 printk(" pc3 - pc3 <addr_min [addr_max]>/off, set break point PC3\n");
436 printk(" daddr0 - daddr0 <addr_min [addr_max] r/w/rw [value]>/off, set break point data address 0\n");
437 printk(" daddr1 - daddr1 <addr_min [addr_max] r/w/rw [value]>/off, set break point data address 1\n");
438 printk(" help - print this screen\n");
446 static int proc_read_pp32(char *page, char **start, off_t off, int count, int *eof, void *data)
448 static const char *stron = " on";
449 static const char *stroff = "off";
460 for ( pp32 = 0; pp32 < NUM_OF_PP32; pp32++ )
464 len += sprintf(page + off + len, "===== pp32 core %d =====\n", pp32);
467 if ( (*PP32_FREEZE & (1 << (pp32 << 4))) != 0 )
469 sprintf(str, "freezed");
477 else if ( PP32_CPU_USER_STOPPED(pp32) || PP32_CPU_USER_BREAKIN_RCV(pp32) || PP32_CPU_USER_BREAKPOINT_MET(pp32) )
480 if ( PP32_CPU_USER_STOPPED(pp32) )
481 strlength += sprintf(str + strlength, "stopped");
482 if ( PP32_CPU_USER_BREAKPOINT_MET(pp32) )
483 strlength += sprintf(str + strlength, strlength ? " | breakpoint" : "breakpoint");
484 if ( PP32_CPU_USER_BREAKIN_RCV(pp32) )
485 strlength += sprintf(str + strlength, strlength ? " | breakin" : "breakin");
488 else if ( PP32_CPU_CUR_PC(pp32) == PP32_CPU_CUR_PC(pp32) )
490 unsigned int pc_value[64] = {0};
493 for ( i = 0; f_stopped && i < NUM_ENTITY(pc_value); i++ )
495 pc_value[i] = PP32_CPU_CUR_PC(pp32);
496 for ( j = 0; j < i; j++ )
497 if ( pc_value[j] != pc_value[i] )
504 sprintf(str, "hang");
507 sprintf(str, "running");
508 cur_context = PP32_BRK_CUR_CONTEXT(pp32);
509 len += sprintf(page + off + len, "Context: %d, PC: 0x%04x, %s\n", cur_context, PP32_CPU_CUR_PC(pp32), str);
511 if ( PP32_CPU_USER_BREAKPOINT_MET(pp32) )
514 if ( PP32_BRK_PC_MET(pp32, 0) )
515 strlength += sprintf(str + strlength, "pc0");
516 if ( PP32_BRK_PC_MET(pp32, 1) )
517 strlength += sprintf(str + strlength, strlength ? " | pc1" : "pc1");
518 if ( PP32_BRK_DATA_ADDR_MET(pp32, 0) )
519 strlength += sprintf(str + strlength, strlength ? " | daddr0" : "daddr0");
520 if ( PP32_BRK_DATA_ADDR_MET(pp32, 1) )
521 strlength += sprintf(str + strlength, strlength ? " | daddr1" : "daddr1");
522 if ( PP32_BRK_DATA_VALUE_RD_MET(pp32, 0) )
524 strlength += sprintf(str + strlength, strlength ? " | rdval0" : "rdval0");
525 if ( PP32_BRK_DATA_VALUE_RD_LO_EQ(pp32, 0) )
527 if ( PP32_BRK_DATA_VALUE_RD_GT_EQ(pp32, 0) )
528 strlength += sprintf(str + strlength, " ==");
530 strlength += sprintf(str + strlength, " <=");
532 else if ( PP32_BRK_DATA_VALUE_RD_GT_EQ(pp32, 0) )
533 strlength += sprintf(str + strlength, " >=");
535 if ( PP32_BRK_DATA_VALUE_RD_MET(pp32, 1) )
537 strlength += sprintf(str + strlength, strlength ? " | rdval1" : "rdval1");
538 if ( PP32_BRK_DATA_VALUE_RD_LO_EQ(pp32, 1) )
540 if ( PP32_BRK_DATA_VALUE_RD_GT_EQ(pp32, 1) )
541 strlength += sprintf(str + strlength, " ==");
543 strlength += sprintf(str + strlength, " <=");
545 else if ( PP32_BRK_DATA_VALUE_RD_GT_EQ(pp32, 1) )
546 strlength += sprintf(str + strlength, " >=");
548 if ( PP32_BRK_DATA_VALUE_WR_MET(pp32, 0) )
550 strlength += sprintf(str + strlength, strlength ? " | wtval0" : "wtval0");
551 if ( PP32_BRK_DATA_VALUE_WR_LO_EQ(pp32, 0) )
553 if ( PP32_BRK_DATA_VALUE_WR_GT_EQ(pp32, 0) )
554 strlength += sprintf(str + strlength, " ==");
556 strlength += sprintf(str + strlength, " <=");
558 else if ( PP32_BRK_DATA_VALUE_WR_GT_EQ(pp32, 0) )
559 strlength += sprintf(str + strlength, " >=");
561 if ( PP32_BRK_DATA_VALUE_WR_MET(pp32, 1) )
563 strlength += sprintf(str + strlength, strlength ? " | wtval1" : "wtval1");
564 if ( PP32_BRK_DATA_VALUE_WR_LO_EQ(pp32, 1) )
566 if ( PP32_BRK_DATA_VALUE_WR_GT_EQ(pp32, 1) )
567 strlength += sprintf(str + strlength, " ==");
569 strlength += sprintf(str + strlength, " <=");
571 else if ( PP32_BRK_DATA_VALUE_WR_GT_EQ(pp32, 1) )
572 strlength += sprintf(str + strlength, " >=");
574 len += sprintf(page + off + len, "break reason: %s\n", str);
579 len += sprintf(page + off + len, "General Purpose Register (Context %d):\n", cur_context);
580 for ( i = 0; i < 4; i++ )
582 for ( j = 0; j < 4; j++ )
583 len += sprintf(page + off + len, " %2d: %08x", i + j * 4, *PP32_GP_CONTEXTi_REGn(pp32, cur_context, i + j * 4));
584 len += sprintf(page + off + len, "\n");
588 len += sprintf(page + off + len, "break out on: break in - %s, stop - %s\n",
589 PP32_CTRL_OPT_BREAKOUT_ON_BREAKIN(pp32) ? stron : stroff,
590 PP32_CTRL_OPT_BREAKOUT_ON_STOP(pp32) ? stron : stroff);
591 len += sprintf(page + off + len, " stop on: break in - %s, break point - %s\n",
592 PP32_CTRL_OPT_STOP_ON_BREAKIN(pp32) ? stron : stroff,
593 PP32_CTRL_OPT_STOP_ON_BREAKPOINT(pp32) ? stron : stroff);
594 len += sprintf(page + off + len, "breakpoint:\n");
595 len += sprintf(page + off + len, " pc0: 0x%08x, %s\n", *PP32_BRK_PC(pp32, 0), PP32_BRK_GRPi_PCn(pp32, 0, 0) ? "group 0" : "off");
596 len += sprintf(page + off + len, " pc1: 0x%08x, %s\n", *PP32_BRK_PC(pp32, 1), PP32_BRK_GRPi_PCn(pp32, 1, 1) ? "group 1" : "off");
597 len += sprintf(page + off + len, " daddr0: 0x%08x, %s\n", *PP32_BRK_DATA_ADDR(pp32, 0), PP32_BRK_GRPi_DATA_ADDRn(pp32, 0, 0) ? "group 0" : "off");
598 len += sprintf(page + off + len, " daddr1: 0x%08x, %s\n", *PP32_BRK_DATA_ADDR(pp32, 1), PP32_BRK_GRPi_DATA_ADDRn(pp32, 1, 1) ? "group 1" : "off");
599 len += sprintf(page + off + len, " rdval0: 0x%08x\n", *PP32_BRK_DATA_VALUE_RD(pp32, 0));
600 len += sprintf(page + off + len, " rdval1: 0x%08x\n", *PP32_BRK_DATA_VALUE_RD(pp32, 1));
601 len += sprintf(page + off + len, " wrval0: 0x%08x\n", *PP32_BRK_DATA_VALUE_WR(pp32, 0));
602 len += sprintf(page + off + len, " wrval1: 0x%08x\n", *PP32_BRK_DATA_VALUE_WR(pp32, 1));
610 static int proc_write_pp32(struct file *file, const char *buf, unsigned long count, void *data)
619 len = count < sizeof(str) ? count : sizeof(str) - 1;
620 rlen = len - copy_from_user(str, buf, len);
621 while ( rlen && str[rlen - 1] <= ' ' )
624 for ( p = str; *p && *p <= ' '; p++, rlen-- );
628 if ( strincmp(p, "pp32 ", 5) == 0 )
633 while ( rlen > 0 && *p >= '0' && *p <= '9' )
639 while ( rlen > 0 && *p && *p <= ' ' )
645 if ( pp32 >= NUM_OF_PP32 )
647 printk(KERN_ERR __FILE__ ":%d:%s: incorrect pp32 index - %d\n", __LINE__, __FUNCTION__, pp32);
652 if ( stricmp(p, "start") == 0 )
654 #ifdef CONFIG_AMAZON_SE
655 *PP32_CTRL_CMD(pp32) = 0;
657 *PP32_CTRL_CMD(pp32) = PP32_CTRL_CMD_RESTART;
659 else if ( stricmp(p, "stop") == 0 )
661 #ifdef CONFIG_AMAZON_SE
662 *PP32_CTRL_CMD(pp32) = 0;
664 *PP32_CTRL_CMD(pp32) = PP32_CTRL_CMD_STOP;
666 else if ( stricmp(p, "step") == 0 )
668 #ifdef CONFIG_AMAZON_SE
669 *PP32_CTRL_CMD(pp32) = 0;
671 *PP32_CTRL_CMD(pp32) = PP32_CTRL_CMD_STEP;
674 else if ( stricmp(p, "unfreeze") == 0 )
675 *PP32_FREEZE &= ~(1 << (pp32 << 4));
676 else if ( stricmp(p, "freeze") == 0 )
677 *PP32_FREEZE |= 1 << (pp32 << 4);
679 else if ( stricmp(p, "unfreeze") == 0 )
680 *PP32_DBG_CTRL(pp32) = DBG_CTRL_RESTART;
681 else if ( stricmp(p, "freeze") == 0 )
682 *PP32_DBG_CTRL(pp32) = DBG_CTRL_STOP;
684 else if ( strincmp(p, "pc0 ", 4) == 0 )
688 if ( stricmp(p, "off") == 0 )
690 *PP32_BRK_TRIG(pp32) = PP32_BRK_GRPi_PCn_OFF(0, 0);
691 *PP32_BRK_PC_MASK(pp32, 0) = PP32_BRK_CONTEXT_MASK_EN;
692 *PP32_BRK_PC(pp32, 0) = 0;
696 addr = get_number(&p, &rlen, 1);
697 *PP32_BRK_PC(pp32, 0) = addr;
698 *PP32_BRK_PC_MASK(pp32, 0) = PP32_BRK_CONTEXT_MASK_EN | PP32_BRK_CONTEXT_MASK(0) | PP32_BRK_CONTEXT_MASK(1) | PP32_BRK_CONTEXT_MASK(2) | PP32_BRK_CONTEXT_MASK(3);
699 *PP32_BRK_TRIG(pp32) = PP32_BRK_GRPi_PCn_ON(0, 0);
702 else if ( strincmp(p, "pc1 ", 4) == 0 )
706 if ( stricmp(p, "off") == 0 )
708 *PP32_BRK_TRIG(pp32) = PP32_BRK_GRPi_PCn_OFF(1, 1);
709 *PP32_BRK_PC_MASK(pp32, 1) = PP32_BRK_CONTEXT_MASK_EN;
710 *PP32_BRK_PC(pp32, 1) = 0;
714 addr = get_number(&p, &rlen, 1);
715 *PP32_BRK_PC(pp32, 1) = addr;
716 *PP32_BRK_PC_MASK(pp32, 1) = PP32_BRK_CONTEXT_MASK_EN | PP32_BRK_CONTEXT_MASK(0) | PP32_BRK_CONTEXT_MASK(1) | PP32_BRK_CONTEXT_MASK(2) | PP32_BRK_CONTEXT_MASK(3);
717 *PP32_BRK_TRIG(pp32) = PP32_BRK_GRPi_PCn_ON(1, 1);
720 else if ( strincmp(p, "daddr0 ", 7) == 0 )
724 if ( stricmp(p, "off") == 0 )
726 *PP32_BRK_TRIG(pp32) = PP32_BRK_GRPi_DATA_ADDRn_OFF(0, 0);
727 *PP32_BRK_DATA_ADDR_MASK(pp32, 0) = PP32_BRK_CONTEXT_MASK_EN;
728 *PP32_BRK_DATA_ADDR(pp32, 0) = 0;
732 addr = get_number(&p, &rlen, 1);
733 *PP32_BRK_DATA_ADDR(pp32, 0) = addr;
734 *PP32_BRK_DATA_ADDR_MASK(pp32, 0) = PP32_BRK_CONTEXT_MASK_EN | PP32_BRK_CONTEXT_MASK(0) | PP32_BRK_CONTEXT_MASK(1) | PP32_BRK_CONTEXT_MASK(2) | PP32_BRK_CONTEXT_MASK(3);
735 *PP32_BRK_TRIG(pp32) = PP32_BRK_GRPi_DATA_ADDRn_ON(0, 0);
738 else if ( strincmp(p, "daddr1 ", 7) == 0 )
742 if ( stricmp(p, "off") == 0 )
744 *PP32_BRK_TRIG(pp32) = PP32_BRK_GRPi_DATA_ADDRn_OFF(1, 1);
745 *PP32_BRK_DATA_ADDR_MASK(pp32, 1) = PP32_BRK_CONTEXT_MASK_EN;
746 *PP32_BRK_DATA_ADDR(pp32, 1) = 0;
750 addr = get_number(&p, &rlen, 1);
751 *PP32_BRK_DATA_ADDR(pp32, 1) = addr;
752 *PP32_BRK_DATA_ADDR_MASK(pp32, 1) = PP32_BRK_CONTEXT_MASK_EN | PP32_BRK_CONTEXT_MASK(0) | PP32_BRK_CONTEXT_MASK(1) | PP32_BRK_CONTEXT_MASK(2) | PP32_BRK_CONTEXT_MASK(3);
753 *PP32_BRK_TRIG(pp32) = PP32_BRK_GRPi_DATA_ADDRn_ON(1, 1);
759 printk("echo \"<command>\" > /proc/driver/ifx_ptm/pp32\n");
760 printk(" command:\n");
761 printk(" unfreeze - unfreeze pp32\n");
762 printk(" freeze - freeze pp32\n");
763 printk(" start - run pp32\n");
764 printk(" stop - stop pp32\n");
765 printk(" step - run pp32 with one step only\n");
766 printk(" pc0 - pc0 <addr>/off, set break point PC0\n");
767 printk(" pc1 - pc1 <addr>/off, set break point PC1\n");
768 printk(" daddr0 - daddr0 <addr>/off, set break point data address 0\n");
769 printk(" daddr1 - daddr1 <addr>/off, set break point data address 1\n");
770 printk(" help - print this screen\n");
773 if ( *PP32_BRK_TRIG(pp32) )
774 *PP32_CTRL_OPT(pp32) = PP32_CTRL_OPT_STOP_ON_BREAKPOINT_ON;
776 *PP32_CTRL_OPT(pp32) = PP32_CTRL_OPT_STOP_ON_BREAKPOINT_OFF;
783 static int stricmp(const char *p1, const char *p2)
789 c1 = *p1 >= 'A' && *p1 <= 'Z' ? *p1 + 'a' - 'A' : *p1;
790 c2 = *p2 >= 'A' && *p2 <= 'Z' ? *p2 + 'a' - 'A' : *p2;
800 static int strincmp(const char *p1, const char *p2, int n)
804 while ( n && *p1 && *p2 )
806 c1 = *p1 >= 'A' && *p1 <= 'Z' ? *p1 + 'a' - 'A' : *p1;
807 c2 = *p2 >= 'A' && *p2 <= 'Z' ? *p2 + 'a' - 'A' : *p2;
815 return n ? *p1 - *p2 : c1;
818 static int get_token(char **p1, char **p2, int *len, int *colon)
822 while ( *len && !((**p1 >= 'A' && **p1 <= 'Z') || (**p1 >= 'a' && **p1<= 'z')) )
834 while ( *len && **p2 > ' ' && **p2 != ',' )
850 while ( *len && **p2 > ' ' && **p2 != ',' )
862 static int get_number(char **p, int *len, int is_hex)
867 if ( (*p)[0] == '0' && (*p)[1] == 'x' )
876 while ( *len && ((**p >= '0' && **p <= '9') || (**p >= 'a' && **p <= 'f') || (**p >= 'A' && **p <= 'F')) )
878 if ( **p >= '0' && **p <= '9' )
880 else if ( **p >= 'a' && **p <= 'f' )
882 else if ( **p >= 'A' && **p <= 'F' )
884 ret = (ret << 4) | n;
891 while ( *len && **p >= '0' && **p <= '9' )
903 static inline void ignore_space(char **p, int *len)
905 while ( *len && (**p <= ' ' || **p == ':' || **p == '.' || **p == ',') )
915 * ####################################
917 * ####################################
923 * ####################################
925 * ####################################
928 static int __init ifx_ptm_test_init(void)
935 static void __exit ifx_ptm_test_exit(void)
940 module_init(ifx_ptm_test_init);
941 module_exit(ifx_ptm_test_exit);