• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /****************************************************************************
2 **+-----------------------------------------------------------------------+**
3 **|                                                                       |**
4 **| Copyright(c) 1998 - 2008 Texas Instruments. All rights reserved.      |**
5 **| All rights reserved.                                                  |**
6 **|                                                                       |**
7 **| Redistribution and use in source and binary forms, with or without    |**
8 **| modification, are permitted provided that the following conditions    |**
9 **| are met:                                                              |**
10 **|                                                                       |**
11 **|  * Redistributions of source code must retain the above copyright     |**
12 **|    notice, this list of conditions and the following disclaimer.      |**
13 **|  * Redistributions in binary form must reproduce the above copyright  |**
14 **|    notice, this list of conditions and the following disclaimer in    |**
15 **|    the documentation and/or other materials provided with the         |**
16 **|    distribution.                                                      |**
17 **|  * Neither the name Texas Instruments nor the names of its            |**
18 **|    contributors may be used to endorse or promote products derived    |**
19 **|    from this software without specific prior written permission.      |**
20 **|                                                                       |**
21 **| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS   |**
22 **| "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT     |**
23 **| LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |**
24 **| A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT  |**
25 **| OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |**
26 **| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT      |**
27 **| LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |**
28 **| DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |**
29 **| THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT   |**
30 **| (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |**
31 **| OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  |**
32 **|                                                                       |**
33 **+-----------------------------------------------------------------------+**
34 ****************************************************************************/
35 
36 
37 #include <linux/stddef.h>
38 
check_stack(unsigned long * base)39 unsigned long check_stack(unsigned long *base)
40 {
41 
42 	register unsigned long sp asm ("sp");
43 	unsigned long retval = sp;
44 	*base = ((sp & ~0x1fff) + 0x380);
45 	return retval;
46 }
47 
check_stack_start(unsigned long * base)48 unsigned long check_stack_start(unsigned long *base)
49 {
50     unsigned long i;
51 	unsigned long from,to;
52 
53 	to = check_stack(&from);
54 	*base = from;
55 
56 	/* run from the stack pointer down to the base */
57 	for (i = from;i<to;i+=4)
58 	{
59 		/* fill up the pattern */
60 		*(long *)i = 0xdeadbeef;
61 	}
62 /*	printk("check_stack_start: from =%x to=%x data=%x\n",from,to,*(long *)(from+4));*/
63 	return to;
64 }
65 
check_stack_stop(unsigned long * base)66 unsigned long check_stack_stop(unsigned long *base)
67 {
68     unsigned long i;
69 	unsigned long from,to;
70 
71 	to = check_stack(&from);
72 	*base = from;
73 
74 	/* run from the stack pointer down to the base */
75 	for (i = from;i<to;i+=4)
76 	{
77 		/* check up the pattern */
78 		if ((*(long *)i) != 0xdeadbeef)
79 			break;
80 	}
81 
82 	/*printk("check_stack_stop: from =%x to=%x data=%x data=%x i=0x%x\n",from,to,*(long *)from,*(long *)(from+4),i);*/
83 	/* return the first time when the pattern doesn't match */
84 	return i;
85 }
86 
87 
88