source: rtems/testsuites/libtests/stackchk/blow.c @ ba6f945a

4.11
Last change on this file since ba6f945a was ba6f945a, checked in by Joel Sherrill <joel.sherrill@…>, on Jun 22, 2010 at 7:59:35 PM

2010-06-22 Joel Sherrill <joel.sherrilL@…>

  • stackchk/blow.c, stackchk/stackchk.scn: Print a stack check report before blowing stack.
  • Property mode set to 100644
File size: 1.2 KB
RevLine 
[ac7d5ef0]1/*  task1.c
2 *
3 *  This set of three tasks do some simple task switching for about
4 *  15 seconds and then call a routine to "blow the stack".
5 *
[08311cc3]6 *  COPYRIGHT (c) 1989-1999.
[ac7d5ef0]7 *  On-Line Applications Research Corporation (OAR).
8 *
[98e4ebf]9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
[2abdd87]11 *  http://www.rtems.com/license/LICENSE.
[ac7d5ef0]12 *
13 *  $Id$
14 */
15
[3a4ae6c]16#include <rtems.h>
[ba6f945a]17#include <rtems/stackchk.h>
[ac7d5ef0]18
[cbc5c46]19void b(void) {}
[ac7d5ef0]20
21void blow_stack( void )
22{
[9919946]23  volatile uint32_t   *low, *high;
[c3e3d07]24  unsigned char *area;
[ac7d5ef0]25
26b();
27  /*
28   *  Destroy the first and last 16 bytes of our stack... Hope it
29   *  does not cause problems :)
30   */
31
[ba6f945a]32  area = (unsigned char *)_Thread_Executing->Start.Initial_stack.area;
[c3e3d07]33
[ba6f945a]34  /* Look in the stack checker implementation for this magic offset */
35  low  = (volatile uint32_t *) \
36     (area + sizeof(Heap_Block) - HEAP_BLOCK_HEADER_SIZE);
37  high = (volatile uint32_t *)
38             (area + _Thread_Executing->Start.Initial_stack.size - 16);
[c3e3d07]39
[ba6f945a]40  low[0] = 0x11111111;
41  low[1] = 0x22222222;
42  low[2] = 0x33333333;
43  low[3] = 0x44444444;
[ac7d5ef0]44
[ba6f945a]45  high[0] = 0x55555555;
46  high[1] = 0x66666666;
47  high[2] = 0x77777777;
48  high[3] = 0x88888888;
49  rtems_stack_checker_report_usage();
[ac7d5ef0]50}
Note: See TracBrowser for help on using the repository browser.