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

4.115
Last change on this file since c499856 was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 1.4 KB
Line 
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 *
6 *  COPYRIGHT (c) 1989-2012.
7 *  On-Line Applications Research Corporation (OAR).
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.rtems.org/license/LICENSE.
12 */
13
14#ifdef HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18#include <rtems.h>
19#include <rtems/stackchk.h>
20
21/* forward declarations to avoid warnings */
22void b(void);
23void blow_stack(void);
24
25void b(void)
26{
27}
28
29void blow_stack(void)
30{
31  volatile uint32_t   *low, *high;
32  unsigned char *area;
33  Thread_Control *executing;
34
35  b();
36
37  /*
38   *  Destroy the first and last 16 bytes of our stack... Hope it
39   *  does not cause problems :)
40   */
41
42  executing = _Thread_Get_executing();
43  area = (unsigned char *)executing->Start.Initial_stack.area;
44
45  /* Look in the stack checker implementation for this magic offset */
46  low  = (volatile uint32_t *) \
47     (area + sizeof(Heap_Block) - HEAP_BLOCK_HEADER_SIZE);
48  high = (volatile uint32_t *)
49             (area + executing->Start.Initial_stack.size - 16);
50
51  low[0] = 0x11111111;
52  low[1] = 0x22222222;
53  low[2] = 0x33333333;
54  low[3] = 0x44444444;
55
56  high[0] = 0x55555555;
57  high[1] = 0x66666666;
58  high[2] = 0x77777777;
59  high[3] = 0x88888888;
60  rtems_stack_checker_report_usage();
61}
Note: See TracBrowser for help on using the repository browser.